web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to update date field using update_recordset in D365FO

(0) ShareShare
ReportReport
Posted on by 230
Hi Team,
 
Using update_recordset i am updating the date.
Below code i am using.
public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)    {        TestStaging    testStaging;               update_recordset testStaging            setting RequestedDeliveryDate = str2Date(subStr(testStaging.DateConvert, 1, 2) + '-' + subStr(testStaging.DateConvert, 3, 2) + '-' + subStr(testStaging.DateConvert, 5, 2), 321)                where testStaging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId &&                      testStaging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup;    }
testStaging.DateConvert = '230314';
 
But in testStaging.DateConvert is sowing null value.
 
If i use select statement and update the RequestedDeliveryDate, i can able to update.
 
Please let me know how to update RequestedDeliveryDate using  update_recordset.
I have the same question (0)
  • Martin Dráb Profile Picture
    240,163 Most Valuable Professional on at
    Let me re-post your code.
    public static void postGetStagingData(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution)
    {
        TestStaging testStaging;
               
        update_recordset testStaging
            setting RequestedDeliveryDate = str2Date(subStr(testStaging.DateConvert, 1, 2) + '-' + subStr(testStaging.DateConvert, 3, 2) + '-' + subStr(testStaging.DateConvert, 5, 2), 321)
            where testStaging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
               && testStaging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup;
    }
     
    I don't think that F&O is able to translate all the X++ functions (such as str2Date()) to T-SQL, so I indeed wouldn't expect it to work.
     
    Can't you parse the DateConvert value inside your entity?
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    306,430 Super User 2026 Season 1 on at
    Hi,
     
    Reading the coding you shared is hard as the format lost the new lines. Anyway, you try to use the update_recordset calculating a field with values from the original records. I don't think the update_recordset will be feasible here. The generated SQL will literally replace the current known values. As the testStaging record in your coding is empty, it will use empty values to update using this command.
    It would be possible if you have a fixed date to update on several records.
  • Suggested answer
    CU27040919-18 Profile Picture
    2 on at
    Hi,
     
    update_recordset cannot use X++ methods. It does not translate them into the SQL ones, but calculates them immediately on the moment of start (once).
     
    to solve your task, you will have to code it as
    while select testStaging
    {
    // do your conversion logic
    testStaging.update();
    }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 396 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 323

#3
Martin Dráb Profile Picture

Martin Dráb 243 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans