web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    236,907 Most Valuable Professional on at
    How to update date field using update_recordset in D365FO
    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
    299,960 Super User 2025 Season 2 on at
    How to update date field using update_recordset in D365FO
    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
    Community member Profile Picture
    2 on at
    How to update date field using update_recordset in D365FO
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 684 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 588

#3
Martin Dráb Profile Picture

Martin Dráb 542 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans