How to generate asset tag automatically in alm_license table?

RK41
Tera Expert

Hi All,

 

I want to generate asset tag value like this SL10001 and its get automatically increment for each inserts. This function only have to work for "Software Entitlement (alm_license)" table and not for "Asset (alm_asset)" table.

 

And I am not interested to use the Number Maintenance function, because it will affect the Asset (alm_asset) table "Asset tag" column as well. So anyone please suggest best practice to achieve this.

 

Thanks,

RK

2 REPLIES 2

dreinhardt
Tera Sage

Hi @RK41,

did you try to link the Number Maintenance to the alm_license table (Software Entitlements)?

We did it and added a BR to copy the value from the number field (u_number, auto created) into the asset tag field on alm_license level only. 

 

Best, Dennis

 

dreinhardt_0-1695540172906.png

dreinhardt_1-1695540259857.png

 

Should my response prove helpful, please consider marking it as the Accepted Solution/Helpful to assist closing this thread.

Riya Verma
Kilo Sage
Kilo Sage

Hi @RK41 ,

 

Hope you are diong great.

 

  1. Create a New Field:

    • Navigate to the "Software Entitlement (alm_license)" table in ServiceNow.
    • Create a new field, let's call it "asset_tag", of type string , "Software Entitlement (alm_license)" table in ServiceNow.. This field will store the generated asset tag.
  2. Create a Business Rule:

    • Create a new business rule named "Generate Asset Tag".
    • Set the condition to run when a new record is inserted into the "Software Entitlement (alm_license)" table.Use Below script in advance tab: 
      (function executeRule(current, previous) {
          // Check if the record belongs to the "Software Entitlement (alm_license)" table
          if (current.getTableName() === 'alm_license') {
              // Generate a unique asset tag
              var assetTag = 'SL' + (current.sys_id.substring(7)); // Assuming sys_id is used and is unique
              current.asset_tag = assetTag;
          }
      })(current, previous);
      ​
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma