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)

Update_recordset

(0) ShareShare
ReportReport
Posted on by 1,875

Hi all

I don't have any compile error but when I execute code axapta throw an error.

Is it possible do this ? (toDate - custAveragePeriodCollectionTrans.DueDate) 

update_recordSet custAveragePeriodCollectionTrans
setting DueDays = toDate - custAveragePeriodCollectionTrans.DueDate;

*This post is locked for comments

I have the same question (0)
  • @rp@n Profile Picture
    30 on at

    Hi Javier

    Can you please let me know the exact error with screen shot.

    Arpan Sen

  • XB Profile Picture
    1,875 on at

    8875.1.png

    Error is for use the expression (toDate - CustAveragePeriodCollectionTrans.DueDate)

  • Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    Hi Javier, it is not possible with the update_recordset statement in X++ to update a field by calculating a value of other fields. In this case you will have to change your code to a record based operation i.e. a while select statement and update each record individually.

  • Mea_ Profile Picture
    60,284 on at

    Hi Javier Biesa,

    Generally you can do this, but this table looks like custom one, what are the types of DueDays and DueDate fields ?

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    msdn.microsoft.com/.../aa865135.aspx

    You may add and subtract date from date, and int from date. If it is of any other type i.e. utcdatetime or int64 it will likely not work. You could try to convert the utcdatetime figures into a date with the DateTimeUtil collection class.

    You could also wrap around the whole arithmetic function with an any2int() to clearly state for whomever is reading the code that you are expecting an integer in the DueDays field.

  • XB Profile Picture
    1,875 on at

    DueDays is an integer and DueDate is a date (EDT DueDate)

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You have 0 value in your record buffer, so date-0=date, which you cannot save in an int field. AX does not work in a way you assume, so the actually selected buffer is not referrable for the set operation.

    You have to join in the datasource once more i.e. using RecId as a link, then you could put that second buffers' value in the deduction.

    See example 3 in the documentation:

    https://msdn.microsoft.com/en-us/library/aa674382.aspx

  • XB Profile Picture
    1,875 on at

    Hi Vilmos

    I saw this links for this reason I was asking if it's possible, I supose  you are right an record buffer is empty.

  • Suggested answer
    shayan arshi Profile Picture
    40 on at

    shayanarshi.blogspot.com/.../update-record-set-using-updaterecordset.html

    This will be helpful to you for insertion

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans