To move existing data from asset tag field to another field and to auto-generate asset tag numbers.

Ayushi J
Tera Contributor

I have created a new custom field as "Customer Asset Tag", on the cmdb_ci table, and now I want to run two fix scripts; 1.) 'To move existing data from the "asset tag" field to newly created custom field in the same  table i.e. cmdb_ci',  2.) 'To auto-generate asset tag numbers for all existing assets in AMDB and CIs in CMDB. These values should auto-generate for both assets and CI's regardless of whether they sync between the two tables. Alphanumeric values will follow the format TESTAT001000001, TESTAT001000002, etc. 

Additionally, a business rule will be need to be developed to create unique asset tags sequentially for all future CI or asset creations.

 

For now I've created a custom field but unable to write the correct fix script as required and also created a 'Before- Insert' business Rule which is not working. So can you all please help with this.

 

Thank You!

 

 

1 REPLY 1

Gurpreet07
Mega Sage

Hi Ayu,

 

To copy the data from asset_tag to new field , simply glide record the table and assign the value to the new field in the while loop.

To set value in the asset_tag field you do not need a business rule. Please use Number maintenance to auto populate the field with new number. This is how incident getting incident number , problem getting problem number. Configure the dictionary for number field on incident table and check the default value in there. That code in a loop can be used to update the existing data. 

https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/administer/field-adm....

 

NOTE:  Asset tag is used as primary key in most of the integrations and you need to review transform maps or any scripts that contains the asset_tag and realign that to the newly created field.