Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Sandeep Rajput
Tera Patron
Tera Patron

Recently, I came across a question where the questioner wanted to remove the asset tag from the Display name field whenever the table was referenced as a reference field in some other table or catalog item/record producer variable.

 

Screenshot 2023-04-30 at 3.26.57 PM.png

 

Questioner was not open for any scripting hence this is the alternative solution I suggested using a function field which was going to use nested GlideFunction calls.

 

1. As a part of the solution one need to define a custom field Asset Name(u_asset_name) on the alm_hardware field. The type of field should be a Function field

Screenshot 2023-04-25 at 6.25.40 PM.png

Here is the Function definition

 

 

 

 

glidefunction:substring(display_name, add(length(asset_tag),4), subtract(length(display_name),add(length(asset_tag),4)))

 

 

 

In this function field, we have used nested GlideFunctions like add, subtract and length inside the substring GlideFunction 

Change the display field as follows. Display Name field should be set to false and Asset name custom field's display field should be set to 'true'.

Screenshot 2023-04-25 at 6.22.54 PM.png

Once done,  this is how your new field Asset name should look

Screenshot 2023-04-25 at 6.27.29 PM.png

Tested the display field by adding a reference field (alm_hardware) on a record producer and it displays the Asset Name field as display field.

Screenshot 2023-04-25 at 6.28.02 PM.pngScreenshot 2023-04-25 at 6.28.13 PM.pngScreenshot 2023-04-25 at 6.28.20 PM.png

Note: Function fields are not stored within database and their value is always calculated whenever the rows from the table are read.

Hope this helps.

Version history
Last update:
‎04-30-2023 03:05 AM
Updated by:
Contributors