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)

Locking a record to a single user for duration of form

(0) ShareShare
ReportReport
Posted on by

Hey,


I am trying to lock a record in the same manner that base ax handles payment journals. The LedgerJournalTable form and table locks for a user when a record is being modified and unlocks when the user either stops editing the record or the AOS crashes. From what I've read, I believe pessimistic locking maybe what I'm looking for. I've also looked through the class JournalFormTable and was a bit overwhelmed on its blocking logic. It seems more complex than what I need for a single table/form.


Does anyone have any reading suggestions? I'm willing to dive in and learn, but I'm at a bit of a loss of where to start. Any suggestion is appreciated.
Thank you!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi Spatton

    It may be helpful to describe the business case /functionality that you are trying to resolve as this would affect the type of locking strategy that you use.

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

    Hi,

    The journals are not using an SQL record lock, but a functional prevention to have two users modifying records in the same journal. So a flag is set on the LedgerJournalTable table to identify someone is using this journal. Then you can't open the lines.

    I would not recommend trying to lock a record on SQL level on a form. Try the same approach as the journals. You can do it more simple compared to the journals. The journals are doing a lot more other things in the system than only locking a journal batch.

  • Community Member Profile Picture
    on at

    Andre,

    Thank you. That is the strategy I tried to go with originally. I have a flag on the table I'm using and flipped it whenever a user opened the form. After a while I noticed a pretty large problem with my implementation. Whenever the AOS crashed, the record would be permanently locked. Do you know of a way to change a value on a table record in the event of an AOS crash?

    Thanks,

    Stephen

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Unfortunately an AOS crash is really an unexpected event, so data-inconsistencies are like this are likely. You could allow the user who locked the record with a flag to disable the flag similar to the way you can unblock journals.

  • Community Member Profile Picture
    on at

    I think that is the strategy I will go with to solve that rare-ish problem. Thank you!

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

    Hi,

    In addition: The Ledger journals are using the SessionId field and SessionLoginDateTime to set the flag. If this session with the login date/time cannot be found anymore, you could add logic to "auto unlock" the record.

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