HI, If you are wondering how to write computed column in entity extension below is the sample piece of code. Step 1: Create a class object extends your entity Step 2: Sample code to get ISO code from LogisticsAddressCountryRegion [ExtensionOf(tableStr(LogisticsAddressCountryRegionTranslationEntity))] public final class LogisticsAddressCountryRegionTranslation_DIS_Extension { public static server str ISOCode_DIS() { SysDictTable dictLogisticsCountryRegion = new SysDictTable(tableNum(LogisticsAddressCountryRegion)); LogisticsAddressCountryRegion logisticsAddressCountryRegion; str countryRegionID = SysComputedColumn::returnField(dataentityviewstr(LogisticsAddressCountryRegionTranslationEntity), identifierstr(LogisticsAddressCountryRegionTranslation), fieldstr(LogisticsAddressCountryRegionTranslation, CountryRegionId)); str val = strFmt("SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4", dictLogisticsCountryRegion.fieldName(fieldNum(LogisticsAddressCountryRegion, ISOcode), DbBackend::Sql), dictLogisticsCountryRegion.name(DbBackend::Sql), dictLogisticsCountryRegion.fieldName(fieldNum(LogisticsAddressCountryRegion, CountryRegionId), DbBackend::Sql), countryRegionID); return val; } } Step 3: Create a unmapped field(required type) in my case its STR.In the property DataEntityViewMethod "LogisticsAddressCountryRegionTranslation_DIS_Extension::ISOCode_DIS" Stpe 4: Create a field in Staging table Step 5: Compile and Synchronise the created objects. Regards, Pradeep
adsenseheader
Tuesday, May 10, 2022
Computed columns on extended data entites in D365 FO
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment