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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Help with update_recordset.

(0) ShareShare
ReportReport
Posted on by 47

Hi Team,

I am using update_recordset but I am not getting expected result.

if (_inventValueExecutionHistory.MainAccountTypeEXP == NoYes::YES)
{
    ttsbegin;
    update_recordset inventValueReportTmpLine
    setting mainAccountId = mainAccount.MainAccountId
        where inventValueReportTmpLine.TransactionId            == _inventValueExecutionHistory.TransactionId
    join generalJournalEntry
        where generalJournalEntry.SubledgerVoucher              == inventValueReportTmpLine.Voucher
    join generalJournalAccountEntry
        where generalJournalAccountEntry.GeneralJournalEntry        == generalJournalEntry.RecId
     join mainAccount
        where mainAccount.RecId                                 == generalJournalAccountEntry.MainAccount;
    
           
    ttscommit;

}

Is this query wrong? using the same query in while statement worked fine.However with this update_recordset query the mainAccountId field is getting updated with one value '1500' in all fields.

Thanks.

I have the same question (0)
  • BringYourOwnDeveloper Profile Picture
    55 on at

    Hi P S,

    you could try to get the translated SQL statement and ananlyze it.

    This way you can see the actually executed SQL and compare it with the while select statement.

    generateonly and info(inventValueReportTmpLine..getSQLStatement()) could be helpful

    With kind regards,

    Oliver

  • Kaushik Parul Profile Picture
    47 on at

    Hi Oliver,  I tried with sql statement this query worked fine..but when I converted this query to update_recordset format..the data is not right..

    My question is do we do update_recordset this way only?

  • BringYourOwnDeveloper Profile Picture
    55 on at

    Hi P S,

    I would also write it this way.

    If I remeber correctly you can also aggregate the where clause, but this might me be even interpreted differently.

    I would search somewhere different.

    Could you please share you while select?

    With kind regards,

    Oliver

  • Kaushik Parul Profile Picture
    47 on at

    if (_inventValueExecutionHistory.MainAccountTypeEXP == NoYes::YES)
    {
        while select forupdate inventValueReportTmpLine
            where inventValueReportTmpLine.TransactionId            == _inventValueExecutionHistory.TransactionId
        {
            select firstonly  generalJournalEntry
                where generalJournalEntry.SubledgerVoucher              == inventValueReportTmpLine.Voucher
            join generalJournalAccountEntry
                where generalJournalAccountEntry.GeneralJournalEntry        == generalJournalEntry.RecId
             join mainAccount
                where mainAccount.RecId                                 == generalJournalAccountEntry.MainAccount;
            
            if (mainAccount)
            {
                ttsbegin;  
                inventValueReportTmpLine.MainAccounId    = mainAccount.MainAccountId;
                inventValueReportTmpLine.update()
                ttscommit;
            }
    }

    Thanks for response Oliver.  Above is the while statement for this query.

  • BringYourOwnDeveloper Profile Picture
    55 on at

    Sure, I hope could help you in the end and do not increase your workload even more.

    Can you modify the while select according to my Code and analyse if it is still updating with different MainAccountIds or now also with only 1500.

    ttsbegin;
    	while select forUpdate * from inventValueReportTmpLine
    		where inventValueReportTmpLine.TransactionId == _inventValueExecutionHistory.TransactionId
    	join generalJournalEntry
    		where generalJournalEntry.SubledgerVoucher == inventValueReportTmpLine.Voucher
    	join generalJournalAccountEntry
    		where generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId
    	join mainAccount
    		where mainAccount.RecId == generalJournalAccountEntry.MainAccount
    	{
    		inventValueReportTmpLine.mainAccountId = mainAccount.MainAccountId,
    		inventValueReportTmpLine.doUpdate();
    	}
    ttscommit;

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi P S,

    Have you already used the debugger to find out if the input values for your update_recordset command are correct and if the correct SQL command is generated?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans