X++ code using getDateDiffWithFallbackToZero of SysComputedColumn to display difference of dates in D365FO.
Hi,
In this post will provide the code to view the difference between two dates using getDateDiffWithFallbackToZero of SysComputedColumn in D365FO.
Setup: Please refer this post to know the details of views DAXCustHistoryInvoices, DAXCustHistoryPayments and data entity DAXCustHistoryTransEntity.
X code using SysComputedColumn with an if loop in D365FO - Dynamics 365 Finance Community
Step 1: Created a new method computeColumnDateDiffToZero(namely) on entity DAXCustHistoryTransEntity.
Step 2: In this method, used getDateDiffWithFallbackToZero method of SysComputedColumn to calculate difference between dates transDate and dueDate of data entity DAXCustHistoryTransEntity and if the result is negative then zero will be displayed.
///
Step 3: Created a new field DatesDiff on entity DAXCustHistoryTransEntity and assigned the method computeColumnDateDiffToZero to it.
On firing the OData call to the entity, received the below output with column DatesDiff showing the difference between the dates (in days) with negative values as zero.

Like
Report
*This post is locked for comments