首页 > 其他分享 >D365: 添加客制化表作为财务维度

D365: 添加客制化表作为财务维度

时间:2022-08-19 15:38:05浏览次数:65  
标签:renamePrimaryKey 化表 capex writeCrossCompany D365 客制 VyaFDCAPEX policy originalRe

1,创建表VyaFDCAPEX

 

 

注意事项

- 必须添加delete,renamePrimaryKey,writeCrossCompany方法

public void delete()
    {
        // Check to see if the associated dimension attribute value has been used
        // in a way that would prevent deletion.
        if (!DimensionValidation::canDeleteEntityValue(this))
        {
            throw error(strfmt("@SYS134392", this.Code));
        }

        ttsbegin;

        // Update the associated dimension attribute value.
        DimensionAttributeValue::updateForEntityValueDelete(this);

        this.writeCrossCompany(tableMethodStr(VyaFDCAPEX, delete));

        super();

        ttscommit;
    }

    public void renamePrimaryKey()
    {
        Common originalRecord = this.orig();

        super();

        DimensionValueRename::syncRenamedValue(this, originalRecord);

        this.writeCrossCompany(tableMethodStr(VyaFDCAPEX, renamePrimaryKey), originalRecord);
    }

    private void writeCrossCompany(str _methodName, Common _originalRecord = null)
    {
        SysDataSharingPolicy policy = SysDataSharingPolicy::findSharingPolicyByCompanyAndTable(curExt(), tableId2name(this.TableId));
        if (policy.RecId && policy.IsEnabled)
        {
            Query       query = SysDataSharingCrossCompanyValidatorQueryBuilder::buildQuery(this.orig(), policy.RecId);
            QueryRun    queryRun = new QueryRun(query);
        
            while (queryRun.Next())
            {
                VyaFDCAPEX companyCAPEX = queryRun.get(this.TableId);
                DataAreaId company = companyCAPEX.DataAreaId;

                if (companyCAPEX && company && company != curExt())
                {
                    changecompany(company)
                    {
                        VyaFDCAPEX capex = VyaFDCAPEX::find(companyCAPEX.Code);
                        if (capex.RecId)
                        {
                            buf2Buf(this, capex);

                            switch (_methodName)
                            {
                                case tableMethodStr(VyaFDCAPEX, delete):
                                    if (!DimensionValidation::canDeleteEntityValue(capex))
                                    {
                                        throw error(strfmt("@SYS134392", capex.Code));
                                    }

                                    DimensionAttributeValue::updateForEntityValueDelete(capex);
                                    break;
                                case tableMethodStr(VyaFDCAPEX, renamePrimaryKey):
                                    DimensionValueRename::syncRenamedValue(capex, _originalRecord);
                                    break;
                                default:
                                    return;
                            }
                        }
                            
                    }
                }
            }
        }
    }

  

2,增加创建主表的窗体,菜单

 

 

 3,增加View VyaFDCAPEXDimensionAttribute

 

 

注意事项

- 视图标签必须指定

- Singular label必须指定

- 数据源名称”必须为“BackingEntity”

- 需要包含三个字段Key, Vaule, Name

- 必须包含Vaule和Name的唯一索引

- 必须包含方法

[SubscribesTo(classstr(DimensionEnabledType), delegatestr(DimensionEnabledType, registerDimensionEnabledTypeIdentifiersDelegate))]
public static void registerDimenionEnabledTypeIdentifier(DimensionIEnabledType _dimensionIEnableType)
{
_dimensionIEnableType.registerViewIdentifier(tableStr(VyaFDCAPEXDimensionAttribute));
}

- 视图必须要有privilege,并将privilege放入到duty(SysServerAXBasicMaintain)中

 

 

 

 

4,打开URL清除缓存

https://*****.sandbox.operations.dynamics.com/?cmp=****&mi=DimensionClearCacheScopes

 

标签:renamePrimaryKey,化表,capex,writeCrossCompany,D365,客制,VyaFDCAPEX,policy,originalRe
From: https://www.cnblogs.com/dingkui/p/16602099.html

相关文章

  • D365: 邮件附件中文名乱码问题
    在D365中,发送QQ,163,Foxmail邮箱如果附件名称中带中文名,收件箱的附件名称出现乱码解决方案增加c#classlibraryusingSystem;usingSystem.Collections.Generic;usin......