X++ code using SysComputedColumn with an if loop and compare expression in D365FO
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".
Step 4: Build the solution. In the table browser able to see the date of delivery of purchase orders.
Output:
Thanks,
Chaitanya Golla

Like
Report
*This post is locked for comments