Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Query::update_recordset Bug

(1) ShareShare
ReportReport
Posted on by 23
Hello,
 
I'm trying to use Query::update_recordset, but I think I found a bug
 
Here is a sample job that I created.
 
If you run that in debug mode, you will see that the method InventTable.Update is always called, even if SkipDataMethods, Events and DatabaseLog are passed as TRUE. The execution revert to a 1 by 1 update operation, thus becoming really slow
 
If I use the update_recordset (not the class) the update method is not called and the execution is fast
 
Maybe this is a bug in the class?
 
 
internal final class TestUpdateRecordSet
{
    /// <summary>
    /// Class entry point. The system will call this method when a designated menu 
    /// is selected or when execution starts and this class is set as the startup class.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        Query q = new Query();
        QueryBuildDataSource qbds = q.addDataSource(tableNum(InventTable));
        qbds.addRange(fieldNum(InventTable, ItemId)).value("020061253001");
              
        Map fieldMap = new Map(Types::String, Types::String);
        fieldMap.insert(fieldStr(InventTable, NetWeight), any2Str("105"));
        Query::update_recordset(fieldMap, q, true, true, true);
    }
}
 
  • Anton Venter Profile Picture
    Anton Venter 18,788 Super User 2024 Season 2 on at
    Query::update_recordset Bug
    Ludovico,
     
    Then it's a bug indeed. Sorry, I totally missed the fact that there is a skipDataUpdate parameter in the Query::update_recordset method.
  • Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    Query::update_recordset Bug
    Hi Ludovico,

    True, based on the link i put in my last reply, it says that we can prevent the fall back for the "update_recordset" if the update method had code, by using "Skip data methods".
     
    So i would assume this link was only talking about the normal update_recordset and not the Query::update_recordset.
    But I agree with you, that the query one should work since they added a parameter called "Skip data methods"  -- maybe you should raise a ticket with Microsoft if you are sure it's not working OR just use update_recordset if it will still work with what you are trying to do.

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
  • Ludovico M. Profile Picture
    Ludovico M. 23 on at
    Query::update_recordset Bug
    Hi Layan, sure, here is the code:
     
    static void Job340(Args _args)
    {
        InventTable inventTable;
        
        inventTable.skipDataMethods(true);
        inventTable.skipDatabaseLog(true);
        inventTable.skipEvents(true);
        
        update_recordSet inventTable
            setting netWeight = 10;
    }
     
     
    This do not call the update method.
     
    If you comment the skip* methods, the update method will be called. 
     
    The same behaviour should apply to the Query::update_recordset method, but the 3 skip* parameters are ignored
  • Layan Jwei Profile Picture
    Layan Jwei 7,347 Super User 2024 Season 2 on at
    Query::update_recordset Bug
    Hi Ludovico,

    Can you show us the code you did for update_recordset where the update wasn't called?

    As far as I'm aware, if InventTable "update" method has some code in it, then there should be a fall back





    Also you could check this link:
    ​​​​​​​Maintain Fast SQL Operations | Microsoft Learn
  • Ludovico M. Profile Picture
    Ludovico M. 23 on at
    Query::update_recordset Bug
    Your answer make no sense to me
     
    There are 3 parameters on the method  Query::update_recordset(fieldMap, q, true, true, true); that are completely ignored and not doing what they should do.
     
    If you need a fast solution and you have Query::update_recordset method, you should definitely be able to use it.
  • Suggested answer
    Anton Venter Profile Picture
    Anton Venter 18,788 Super User 2024 Season 2 on at
    Query::update_recordset Bug
    Probably not a bug and is functioning as designed with the idea of if you need a fast solution, you could use the update_recordset statement.

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans