- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 10:47 PM
Hello!
I have a catalog item with a single-text variable called Location. The value that populates this variable is in the Location table. In the workflow, I want to write a script that gets a field value from the Location table. Is this possible using the single-text variable?
I am pretty sure there is a way if the variable is a reference type but unfortunately the original designer of the catalog item used another variable type.
Please help.
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 10:54 PM
You can still change it to reference variable, but if for some reason you want to keep as single line text only then you can write a script like below, but in this case you have to make sure name is entered properly in the single line text field.
var getLocation = new GlideRecord('cmn_location');
getLocation.addQuery('name', current.variables.SINGLELINEVARIABLENAME);
getLocation.query();
if(getLocation.next()){
//do something
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 10:54 PM
You can still change it to reference variable, but if for some reason you want to keep as single line text only then you can write a script like below, but in this case you have to make sure name is entered properly in the single line text field.
var getLocation = new GlideRecord('cmn_location');
getLocation.addQuery('name', current.variables.SINGLELINEVARIABLENAME);
getLocation.query();
if(getLocation.next()){
//do something
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 11:10 PM
Hi,
the only way is to query cmn_location table with that single line text variable and get the record.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 11:18 PM
Hi,
Are you validating the value entered in this field before form submission? If not you will face issue in the workflow.
I suggest you to convert this variable to Reference. Converting the variable type will not impact the already submitted RITMs. This change will reflect only the new RITMs create after this conversion.
Thank you,
Palani
Palani