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

Is it possible to update the last modified date of an object/table through document services?

(0) ShareShare
ReportReport
Posted on by 415

I am creating a synchronization process to keep data in sync with outside sources.  It is key for me to be able to update that last modified date.

Anybody help on this would be greatly appreciated.

 

Thanks,

Jason Lambert

*This post is locked for comments

I have the same question (0)
  • Jason Lambert Profile Picture
    415 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    You were right.   You can't view the new modifiedDateTime until after the super() but you need to set the value before the super so you can't set the value to that.  I did what you said and just set it to be the current date and time.  The date and time are close enough.

  • Denis Patrakov Profile Picture
    on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    Note also that if you have your code called in update() before super() you shouldn't expect the modifiedDateTime field to have it's actual value (the one it will have after super()). When the AX kernel updates a record it sends a statement like update SomeTable set fld1=@in1, fld2=@in, modifiedDateTime=SYSUTCDATETIME() output inserted.modifiedDateTime... So if you need to know the modifiedDateTime value before the actual update you can use DateTimeUtil::utcNow() although it will return not exactly the same value.

  • Jason Lambert Profile Picture
    415 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    Since I can't update the modifiedDateTime field directly I am just going to create a new field and have it update that field when the modifiedDateTime field updates.  

  • Verified answer
    Denis Patrakov Profile Picture
    on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    [quote user="Brandon Wiese"]if you set the method .overwriteSystemFields(true) on a record, then it will let you change the created/modified fields.[/quote]This only works when you insert a record, but not when you update it. Otherwise it would ruin the Audit Trial feature, for instance.
    [quote user="Jason Lambert"]It is key for me to be able to update that last modified date.[/quote]Sorry, but I'm afraid you can't do that using any means provided by the AX kernel except for direct SQL statements.
    Anyway, if for some reason you need to set the modifiedDateTime field value to something other then the current UTC date/time (which you generally get in case you update a record) then you might use other options like USN (Update Sequence Number) in Active Directory, see this technet article for details.

  • Suggested answer
    JohnRobertson Profile Picture
    on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    check the Class\AxGenerateAXBCClass and method generate

    comment out:

    fieldcnt = sytDictTable.fieldCntWithoutSys();

    replace with

    fieldCnt = sysDictTable.fieldCnt();

    This change allows you to expose the System Generated fields like ModifiedDateTime and CreatedDateTime

    certainly for inbound aif calls you can query over the data using the dateTime fields.

  • Jason Lambert Profile Picture
    415 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    That would work if I was in the client but since I am doing it via AIF document services I don't think that is going to work for me.  I haven't figured out a way to expose it via document services for one thing.  And I don't think i would be able to call the overwriteSystemFields function through there.  I could be wrong though.

  • Brandon Wiese Profile Picture
    17,788 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    if you set the method .overwriteSystemFields(true) on a record, then it will let you change the created/modified fields.  You can find examples of this in the BatchRun class.

  • Jason Lambert Profile Picture
    415 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    Yeah, i think I may need to do what you said and create a new field and then sync it.  This is for a data synchronization utility I am creating to sync data between ax and salesforce.  It would be nice to update the actual fields.  I use this to figure out when things have changed.  So I would need to create logic to update this new field anytime there is a change to a record.  

    So you would say the best place to put that logic would be in the update method of the table?

    Thanks for the advice.

    Jason

  • Klaas Deforche Profile Picture
    2,433 on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    Hi Jason,

    I agree with Martin, it would be better to add a new field (and leave it at that).

    If storing the datetime in the new field is ok, you're all set,

    and if it's not, and your really (really really) want to update the modifieddatetime, you could still sync the two fieldst in the update method of your table. Then there is no need to modify the framework.

    It's not pretty, but I understand you want to do those kind of things sometimes :).

  • Martin Dráb Profile Picture
    235,928 Most Valuable Professional on at
    Re: Is it possible to update the last modified date of an object/table through document services on Dynamics AX 2012?

    These system fields are not intended to be changed by anybody else than the AX kernel (regardless whether it is possible or not). Why don't you just make a new field for your purposes?

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans