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 statement not working. The same with while select forUpdate works..

(0) ShareShare
ReportReport
Posted on by 1,087

Hi,

any known issues about this?

I've encountered a custom method which tries to update a set of record by joining 2 tables with the update_recordset statement. Something like:

update_recordset myTable1
                            setting [fieldsList]
                            join myTable2
                                where [conditions]

The instruction returns this error "could not update a record" and i can see this join doesn't retrieves anything.

If i do the same with a "while select forUpdate" statement, it works fine. The records are retrieved and updated.
Obviously this takes much more time than the update_recordset.

Any idea about this issue?

Thank you in advance

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Can you show us your actual code and copy the exact wording of the error message, please?

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Hi win32,

    Please share your actual code which is working for while select statement and not with update_recordset then we will be able to find the exact missing point from there. For your reference I am sharing a small concept on update_recordset, it may help you but important to share your code.

    daxture.blogspot.com.au/.../all-about-updaterecordset.html

  • vv1984 Profile Picture
    1,087 on at

    I've "translated" this update_recordSet into the while select below.

    The value "revLine.RevisionPercent/revPercentDiv" previously led to "division by zero" error inside the select while. Could be that the cause?

    Anyway, the update_recordSet was not retrieving anything...

    update_recordset salesLine_update
    setting RevisionSalesQty = revLine.RevisionPercent/revPercentDiv
    join revLine
    where !revLine.SalesId &&
    revLine.ItemGroupId == salesLine_update.ItemGroupId &&
    revLine.RevisionId == RevisionId &&
    salesLine_update.Runnumber == RSRun_loc.Runnumber;

    //This one works fine
     while select forUpdate salesLine_update
     join revLine
     where !revLine.SalesId &&
     revLine.ItemGroupId == salesLine_update.ItemGroupId &&
    revLine.RevisionId == RevisionId &&
     salesLine_update.Runnumber == RSRun_loc.Runnumber
    {

    if(revPercentDiv!=0)
        RevisionSalesQty = revLine.RevisionPercent/revPercentDiv;

    }

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Divisiobn by zero obviously is a problem. Please do the check before even trying to run your query.

    First of all, try setting a fixed value (setting RevisionSalesQty = 42). If it works, use the field from the child record (setting RevisionSalesQty = revLine.RevisionPercent). If it works, add the expression (/revPercentDiv). That should give you a better idea what exactly doesn't work; trying to debug many things at once usually doesn't bring any result at all. I'm not sure that the last case is supported by update_recordset.

    Also, can you give us the error message?

  • Verified answer
    vv1984 Profile Picture
    1,087 on at

    Yes guys, it seems that the division by zero throws that error on the update_recordSet statement.

    update_recordset myTable1

                               setting numericField/divisionField

                               join myTable2

                                   where [conditions]

    if divisionField equals zero, Ax returns the following:

    Cannot edit a record in myTable1 (myTable1Name). [...] SQLdatabase error.

  • vv1984 Profile Picture
    1,087 on at

    The error message is in italian. I've tried to look for it in the label editor, but could not find the exact entry.

    But it is something like "could not update a record in table %1 .... SQL database error"

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