Skip to main content

Notifications

Announcements

No record found.

X++ code using SysComputedColumn to use Comparison expression list in D365FO

Hi,

In this post we will view the code to use comparison expression list on SysComputedColumn in D365FO.

Please refer to this post to know about the details of the view DAXCustVendExternalItem.

X code using SysComputedColumn to use codeDependentRelation expression in D365FO - Dynamics 365 Finance Community

Step 1: Created a new field on the view DAXCustVendExternalItem by name ModuleType.

Step 2: Created a method "computeColumnModuleType" to display the value of field "Module type" as "Customer" if ModuleType enum is Cust (ModuleInventPurchSalesVendCustGroup::Cust) else display as "NotCustomer".

    private static str computeColumnModuleType()
    {
        List moduleTypes = SysComputedColumn::comparisionExpressionList();
        str moduleTypeField = SysComputedColumn::comparisonField(tableStr(DAXCustVendExternalItem),
                tableStr(CustVendExternalItem), fieldStr(CustVendExternalItem, ModuleType));

        moduleTypes.addEnd(SysComputedColumn::equalExpression(moduleTypeField,
            SysComputedColumn::comparisonLiteral(ModuleInventPurchSalesVendCustGroup::Purch)));
        moduleTypes.addEnd(SysComputedColumn::equalExpression(moduleTypeField,
                SysComputedColumn::comparisonLiteral(ModuleInventPurchSalesVendCustGroup::Sales)));
        moduleTypes.addEnd(SysComputedColumn::equalExpression(moduleTypeField,
            SysComputedColumn::comparisonLiteral(ModuleInventPurchSalesVendCustGroup::CustGroup)));

        return SysComputedColumn::if(SysComputedColumn::or(moduleTypes),
                SysComputedColumn::returnLiteral("NotCustomer"),
                SysComputedColumn::returnLiteral("Customer"));
    }

Step 3:   Assigned view method "computeColumnModuleType" to the field "ModuleType".

4152.CompExpList1.jpg

Step 4: Build the solution. In the table browser able to see ModuleType field values.

Output:

0312.CompExpListOutput.jpg

Regards,

Chaitanya Golla

Comments

*This post is locked for comments