duplication of an auto generation field when users create at same time

saibharath
Tera Contributor

Hi 

 

when users are trying to create an asset, the asset tag is autogenerated, but there is an issue which is rarely happening when users try to create an asset at same time  , asset tag is being duplicated i.e 2 assets are having same asset tag.  can anyone suggest the solution for it.

How code is written:

we are calling a scriptinlcude inside a business rule for asset tag  generation.


solutions suggested in other forums but did not understand or get the way how it shoud be done:

 

  • lock the counter table if one is using it
  • increase counter immediately if one query is happening
  • pipeline users in queue - fifo manner

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@saibharath 

So you need to debug and understand that script include and business rule

What debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

i debugged the code it's just assigning the asset tag basing on few conditions but i want to know how we can

stop creating duplicate asset tags when 2 users try to create an asset?

@saibharath 

why 2 users are creating same asset at same time?

you can validate if the asset tag is already being used before assigning it

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

sorry for late reply, actually the asset tag is auto generated depending upon few conditions and now when we are calling the script include from before business rule where the code is written in script include, we have counter field which increases everytime an asset is created and the counter field is appended in the end of asset tag, now when 2 users are creating at same time and the condition of the assets which are being created match we are getting same asset tag in that case, maybe because counter which is being appended in the end is same too , also sys_created is also same for newly created assets with same seconds too