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, ...
Suggested Answer

Cannot edit a record in LastValue (SysLastValue) - Error in multi threaded batch job

(0) ShareShare
ReportReport
Posted on by 20
Hi All,
 
I am getting below error during batch job execution,
 
Cannot edit a record in LastValue (SysLastValue).An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.
 
I tried with table.reread() before updating the record but it is not helping.
 
Note : We have a mitithreaded process when create/update is happening in UserInfo, SysUserInfo, SecurityUserRole tables.
 
Any help would be highly appreciated.
 
Thank you!
I have the same question (0)
  • Jonas "Jones" Melgaard Profile Picture
    4,980 Most Valuable Professional on at
     
    What exactly are you doing, what are you rereading?
    For me it sounds like you are updating the same record in all of your batch threads, then I'd say it's expected that it complains about update conflicts.
     
     
     
     
  • Suggested answer
    Saif Ali Sabri Profile Picture
    2,351 Super User 2025 Season 2 on at
    This error occurs due to concurrency conflicts when multiple threads try to update the SysLastValue table simultaneously. Since SysLastValue is used to store the last used values for different processes, concurrent updates can lead to conflicts.
    Solution:
    1. Use RecordSelectLock for exclusive access
      Before updating SysLastValue, lock the record to prevent conflicts:
    x++
     
    ttsBegin;  
    SysLastValue lastValue;  
    select forUpdate lastValue  
        where lastValue.ElementName == 'YourElementName';  
    if (lastValue)  
    {  
        lastValue.Value = 'YourUpdatedValue';  
        lastValue.update();  
    }  
    ttsCommit;  
     
    2. Retry logic in case of conflicts
    Implement a retry mechanism using retry keyword to handle intermittent failures:

    x++

    int retryCount = 3;  
    while (retryCount > 0)  
    {  
        try  
        {  
            ttsBegin;  
            select forUpdate lastValue  
                where lastValue.ElementName == 'YourElementName';  
            if (lastValue)  
            {  
                lastValue.Value = 'YourUpdatedValue';  
                lastValue.update();  
            }  
            ttsCommit;  
            break;  
        }  
        catch (Exception::UpdateConflict)  
        {  
            retryCount--;  
            if (retryCount == 0)  
            {  
                throw error("Update conflict on SysLastValue. Please try again.");  
            }  
        }  
    }  
    1. Ensure transactions are correctly scoped
      • Avoid holding locks for long durations.
      • Only update SysLastValue when necessary.
      • Run batch jobs with a single thread if SysLastValue updates are critical.
    By implementing these solutions, you should reduce update conflicts and ensure smooth batch processing.

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 565 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