How to validate entries by recording record types?

I created a button in a Suitelet form which call a function to save a generated number adding one to the last generated in a custom record type, the button works and it save the new number as it is expected, the problem is when more than one user click the button at the same time to generate a new number, it supposed to give a different number for each one, but it return the same number. How do I validate to give a new number even if the button is clicked by two or more users?

here is part of my code:

Suitelet (button):

How to validate entries by recording record types?


Client (function for the button):

How to validate entries by recording record types?


Thanks in advance.

Rookie Asked on August 19, 2020 in SuiteScript.
Add Comment
2 Answer(s)

I think you’d have to implement some sort of record locking so that you first obtain a lock on the record before updating the ID.

Other instances of the same script should retry until they obtain a lock.

As such, use some ID known only to the current instance of the script to perform the lock.

Hope that makes sense and happy to answer any further questions.

Intermediate Answered on August 19, 2020.

Thank you abbott! Can you give me an example of this? Sorry, I’m very new in this and I don’t know how to do it 🙂

on August 20, 2020.
Add Comment

Hi, I solve the problem moving the “dialog.alert” after the first “lookupFields” and deleting the other one, in that way always is giving me a new number even if users click the button at the same time.

Rookie Answered on August 21, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor