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 to get current date and current date time in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

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.

pastedimage1674073177301v1.png

Regards,

Chaitanya Golla

Comments

*This post is locked for comments