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 :
Microsoft Dynamics AX (Archived)

System "Modified By" field Overwrite During Update

(0) ShareShare
ReportReport
Posted on by

I have successfully created code to change the Created By and Modified By fields when Sales Quotes are created in Microsoft CRM and imported into DAX 2012 so that the service account UserID is not used.

By running the following before insert:


                new OverwriteSystemfieldsPermission().assert();
                quotationTable.overwriteSystemfields(true);
                quotationTable.(fieldNum(SalesQuotationTable, CreatedBy))           = userInfo.Id;
                quotationTable.(fieldNum(SalesQuotationTable, CreatedDateTime))     = DateTimeUtil::getSystemDateTime();
                quotationTable.(fieldNum(SalesQuotationTable, ModifiedBy))          = userInfo.Id;
                quotationTable.(fieldNum(SalesQuotationTable, ModifiedDateTime))    = DateTimeUtil::getSystemDateTime();
                CodeAccessPermission::revertAssert();

Problem now is when Sales Quotes are updated in CRM and those updates are pushed to DAX 2012, the updates reflect the service account UserID.

I tried the following prior to update:

new OverwriteSystemfieldsPermission().assert();
quotationTable.overwriteSystemfields(true);
quotationTable.(fieldNum(SalesQuotationTable, ModifiedBy))          = userInfo.Id;
quotationTable.(fieldNum(SalesQuotationTable, ModifiedDateTime))    = DateTimeUtil::getSystemDateTime();
CodeAccessPermission::revertAssert();

Can changes only be done during insert?

Why would it allow changes during insert and not be able to change modified by during updates?

Any feedback would be appreciated.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If you have the properties set on the table to populate those fields, whenever you do an update, the AX kernel will stamp the records after your update in a separate statement with the current userid and datetime. So even if you defined your values, that will be overwritten. If you want to always provide your own values, I am afraid you need to disable the settings on the table, however with that you lose tracking those values when you call a doUpdate(), or it is not coming through a scenario where you deliberately populate the values (your CRM import routine).

    I would just create a custom created/modified by field and populate those, rather than bothering overriding system fields. You could also force populating the values in case of doInsert/doUpdate method calls if you place the logic to fill the fields for example in the aosValidate* methods, since that is always called.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans