X++ code using SysComputedColumn to get current date and current date time in D365FO
Hi,
In this post, will provide the code to get current date and current date time using methods getCurrentUtcDate and getCurrentUtcDate of SysComputedColumn respectively 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 methods computedCurrentDate and computedCurrentUtcDate(namely) on entity DAXCustHistoryTransEntity.
Step 2: In the method computedCurrentDate, used computedCurrentDate and in method computedCurrentUtcDate used method getCurrentUtcDate of SysComputedColumn respectively.
Method: computedCurrentDate
private static str computedCurrentDate()
{
return SysComputedColumn::getCurrentUtcDate();
}
Method: computedCurrentUtcDate
private static str computedCurrentUtcDate()
{
return SysComputedColumn::getCurrentUtcDate();
}
Step 3: Created a new fields CurrentDate and CurrentUtcDateTime on entity DAXCustHistoryTransEntity and assigned the methods computedCurrentDate and computedCurrentUtcDate to it respectively.
Output:
On firing the OData call to the entity, received the below output with columns CurrentDate and CurrentUtcDateTime showing the current date and current date time respectively.
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments