Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

How to update the modified by field in ax?

Posted on by 162
Hi,
As the modified by field is having values '?', the client wants to update it with created by  values. I tried the following code. While I debug the value is updated but when I check the SQL, the value is still '?'. Let me know where am I wrong.
 
public static void main(Args _args)    {        GeneralJournalEntry     generalJournalEntry;        while select forupdate * from generalJournalEntry where            generalJournalEntry.RecId ==5637144588 && generalJournalEntry.ModifiedBy == '?'        {                            ttsbegin;                generalJournalEntry.overwriteSystemfields(true);                generalJournalEntry.(fieldNum(GeneralJournalEntry,ModifiedBy))          = generalJournalEntry.CreatedBy;                generalJournalEntry.(fieldNum(GeneralJournalEntry,ModifiedDateTime))    = generalJournalEntry.CreatedDateTime;                generalJournalEntry.doUpdate();                ttscommit;                      }            }
 
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    How to update the modified by field in ax?
    overwriteSystemfields() is used for inserts and its ignored on updates, as far as I know.
    ModifiedBy and ModifiedDateTime would update automatically if the record was updates, but in your case, the system notices that you changed no field and therefore it won't actually send an update to database.
  • Harshal Jain Profile Picture
    Harshal Jain 162 on at
    How to update the modified by field in ax?
    Hi Andre,
    Thanks for suggestion. Will check with customer. Also can you tell why this is code is not working?
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,240 Super User 2024 Season 2 on at
    How to update the modified by field in ax?
    Hi Harshal,
     
    This is a type of request, I would try to convince the customer not making any change. It is a default behavior of AX to put a question mark in case the system field is enabled after go live. Anyway, you can also update the values in SQL server itself with a script. 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans