what is the use of LOCK in workflow

chanikya
Tera Guru

Hi,

please explain about Lock , how it will works ??   and Don't Copy paste servicenow wiki information.

explain it in real time scenario 

1 ACCEPTED SOLUTION

If you use it right, you can set it up that way, but I wouldn't. You can't be sure that access runs first or iphone runs first.

Based on your use case, you don't need a lock.

If you had a case where iPhones were being requested several times an hour, then you might consider one. Let's say you are keeping track of an inventory count of how many iPhones you have. That inventory table has a "unit" and "quantity". I would consider using a lock on the workflow when the workflow gets to the point when it needs to decrement the count from that table. If you had all workflows accessing at the same time, your count would be off for that record. If you use a lock, you ensure only one record is decrementing at a time.

Again, it doesn't sound like you need a lock so don't bother.

View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

It's mean to prevent resource contention issues. if you have multiple workflow contexts all vying for the same resource, lock and unlock allow one context to work on it at a time. The lock prevents any other contexts from running past the lock activity if the lock has been obtained by another WF context.

Example: You might start multiple VMs at the same time and they all want to run something in roughly the same time. To allow a "who go here first?" scenario and let only that workflow update, you use a lock. When that WF is done with the resource, you unlock, and another WF context gets to run.

Docs: Workflow lock activity

Hi Tomasi,

 

i have one workflow in Incident , if i set LOCK in that workflow how it works?

OR

i have one workflow in Catalog Item, if i set LOCK  in that workflow how it works?

It means that no other catalog items (or incidents) that use that use that same workflow, can get past the lock until the first one releases the lock with unlock.

If you don't have any resource contention problems, then you don't need it and I wouldn't bother using it. It's only needed in rare situations when multiple workflows are trying to update the same records at the same time. This is usually not the case.

means i use ABC -workflow in Catalogs( Access, IPhone7s)

if i generated two items at a time ( first time - Access,  Second time- IPhone7s)  , it will accept first ACCESS, when ACCESS was completed, then after only it will accept second catalog item  

 

i am right??