how to concatenate two reference fields in string field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 10:50 PM
Can two reference fields are concatenated? If so how this can be achieved?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 10:57 PM
If your reference fields are the same you can use a List field that references the desired table.
This will allow you to store multiple records in one field.
The watch list field is an example of this, where multiple users can be added.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 12:57 AM
I guess what I'm getting at is there may be a better technical solution than just concatenating two sys_id's in a string field.
What outcome are you actually trying to achieve here? Have you considered using a List field?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 11:10 PM
Hi,
Take two values of the reference field. and convert it to String using toString() function.
concatewith string inbuilt function or '+' and assign it to the one more string variable.
Example:
var string1;
var string2=<reference fieldname>.toString();
var string3=<reference fieldname>.toString();
var string1=string2+string3;//or var string1=concate(string2,string3);//please check the cancate function syntax.
Thanks,
Veeresh
Please mark as correct , if it's helpfull.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2018 07:05 AM
instead of toString(), we can use getDisplayValue() function in a very similar fashion.
var final_str = ref_field_1.getDisplayValue() + ":" + ref_field_2.getDisplayValue() ;
In a table, if you want to concatenate 2 fields of reference type into a new field with string type
- Add a new field for eg. Full Name
- edit this field and got to Calculated value tab
- Put this script there
(function calculatedFieldValue(current) {
var fullname = current.u_first_name.getDisplayValue() + ':' + current.u_last_name.getDisplayValue() ;
return fullname;
})(current);