web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

X++ code using SysComputedColumn with an if loop and compare expression in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In this post, we will view the code to use SysComputedColumn with if loop and compare expression in D365FO

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

( ) X code using SysComputedColumn with a SQL query in D365FO. - Dynamics 365 Finance Community

Step 1: Created a new field on the view DAXPurchAgreementDetails by name DateofDelivery.

Step 2: Created a method "computeDateofDelivery" to display the date of delivery, where if "confirmed delivery date" is greater than "deliver date" display "confirmed delivery date" or else display "delivery date" of purchase order.

public static str computeDateofDelivery()
    {
        var viewName              = tableStr(DAXPurchAgreementDetails);
        var deliveryDate          = SysComputedColumn::returnField(viewName, tableStr(PurchTable), fieldStr(PurchTable, DeliveryDate));
        var confirmedDeliveryDate = SysComputedColumn::returnField(viewName, tableStr(PurchTable), fieldStr(PurchTable, ConfirmedDlv));

        return SysComputedColumn::if(SysComputedColumn::compareExpressions(confirmedDeliveryDate, '>', deliveryDate),
                                                                           confirmedDeliveryDate,
                                                                           deliveryDate);
    }

Step 3:   Assigned view method "computeDateofDelivery" to the field "DateofDelivery".

8424.DateOfDelivery1.jpg

Step 4: Build the solution. In the table browser able to see the date of delivery of purchase orders.

Output:

1856.DateOfDeliveryOutput.jpg

Thanks,

Chaitanya Golla

Comments

*This post is locked for comments