Hi,
In this post, we will view the code to use SysComputedColumn with if loop and not equal expression.
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 DeliveryDate.
Step 2: Created a method "computeDeliveryDate" to display the confirmed delivery date if it is not null, else display delivery date of purchase order.
public static str computeDeliveryDate()
{
var viewName = tableStr(DAXPurchAgreementDetails);
var deliveryDate = SysComputedColumn::returnField(viewName, tableStr(PurchTable), fieldStr(PurchTable, DeliveryDate));
var confirmedDeliveryDate = SysComputedColumn::returnField(viewName, tableStr(PurchTable), fieldStr(PurchTable, ConfirmedDlv));
var isDeliveryDateConfirmed = SysComputedColumn::notEqualExpression(
SysComputedColumn::comparisonField(viewName, tableStr(PurchTable), fieldStr(PurchTable, ConfirmedDlv)),
SysComputedColumn::comparisonLiteral(dateNull()));
return SysComputedColumn::if(isDeliveryDateConfirmed, confirmedDeliveryDate, deliveryDate);
}
Step 3: Assigned view method "computeDeliveryDate" to the field "DeliveryDate".
Step 4: Build the solution. In the table browser able to see the delivery date of purchase orders.
Output:
Thanks,
Chaitanya Golla
*This post is locked for comments