How to generate asset tag automatically in alm_license table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 04:44 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 12:24 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 01:31 AM
Hi @RK41 ,
Hope you are diong great.
-
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.
-
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);
Regards,
Riya Verma