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.

URGENT! How to convert SysID to Value?

Anonym
Kilo Expert

Hey, I auto-populate values of a contract with the details of a related task record by using a business rule and a client script. Most of the populated fields work but some populated display not the Value of the related field but the Sys ID. How can I convert this to a normal value using my BR and CS? 

Some information about the needed code and where to insert would be very helpful.

Thank you for your efforts.

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Reference fields store sys_ids and display whatever the Display column of the reference table is.  If you're not populating this into a field referencing the same table, where you would want to use the sys_id, you can get the display value instead of the sys_id using something like

user = field_name.getDisplayValue();

instead of just

user = field_name. 

If it's still not working for you posting your scripts would be very helpful.

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

Reference fields store sys_ids and display whatever the Display column of the reference table is.  If you're not populating this into a field referencing the same table, where you would want to use the sys_id, you can get the display value instead of the sys_id using something like

user = field_name.getDisplayValue();

instead of just

user = field_name. 

If it's still not working for you posting your scripts would be very helpful.

It works, thank you very much!

Do you have an Idea how I can add line-breaks to a text field by using javascript code?

I have added \n to the contents of a text field, and it translates that when displaying the value into a new line.

Awesome, thank you!

Last Question for today 😉 

Is it possible to make text bold or underline the text in a such a text field?