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, ...
Answered

custom script doesnt complete test

(1) ShareShare
ReportReport
Posted on by 96
I am trying to execute a custom script in D365 FnO. When I run the test. it starts correctly but after some time page is auto-refreshed and returns to the dashboard without any message.
When I navigate back to the custom script page, the script is still there with the status approved and I can see that records were being processed before it abruptly refreshed and moved to the dashboard.
 
Is there a standard timeout on the custom scripts?
 
My custom script will update a column for 5K records in a table based on a condition. The column being updated is just for information and doesn't trigger any other business logic.
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at
    Hi Sunil,
     
    Can you tell if the script while testing did update all records correctly? I'm not sure about a timeout, but at least the client user interface has a timeout.
    Can you tell if the column should be changed with the same value for all the records when they meet the condition? If so, you can use a statement update_recordset which will be faster if you haven't use this statement already.
    If you share your coding, we can check it and see if you can gain performance.
  • SunilSharma Profile Picture
    96 on at
     
    Thanks Andre.
     
    In the log for the execution, it seems script ran for 2-3 minutes and then stopped without any error.
    If you see below test run has started. But this has never completed nor gave any error. it still says status as approved.
     
    Below is my code snippet :
     
    SalesTable salesTable;
        
                while select forupdate salesTable
                    where salesTable.SalesStatus != SalesStatus::Invoiced
                    && (salesTable.CustAccount == '10000' || salesTable.CustAccount == '10001')
                {
                    salesTable.MBSInvoiceDateDeliveryDate = true;
                    //salesTable.update();
                    salesTable.doUpdate(); 
                }
  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at
    Hi Sunil,
     
    Performance-wise, you can approach the script differently. As mentioned in my previous reply, you can use update_recordset for better performance. It will then send only one command to the SQL database instead of one for each of your 5K records. I would suggest using the code below and check if that solves your issue.
     
    SalesTable salesTable;
    
    update_recordset salesTable;
        setting
            MBSInvoiceDateDeliveryDate = true
        where salesTable.SalesStatus != SalesStatus::Invoiced
           && (salesTable.CustAccount == '10000' || salesTable.CustAccount == '10001');
    
     
  • Verified answer
    Martin Dráb Profile Picture
    237,904 Most Valuable Professional on at
    André is right about update_recordset, but one thing is missing in his code. If update() method is overridden,
    events are subscribed to OnUpdating/OnUpdated (and a few other reasons), processing is done by row-by-row anyway instead of merely sending a single UPDATE commend to database. To solve this problems, methods like skipDataMethods(true) and skipEvents(true) need to be called before update_recordset, assuming that skipping all the business logic is safe in this case.
  • SunilSharma Profile Picture
    96 on at
     Thanks Martin and Andre.
     
    I managed to solve the issue.
    Need to add skipDataMethods(true) and skipEvents(true) before update_record so processing is done by a single UPDATE command to database.

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 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans