- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2020 05:03 PM
Hi SNOW Dev,
Is it possible to assign a string value to a reference field? For example,assignment group is a reference field, and I'd like to assign "Team Acme" (String) to an assignment group field like the below.
assignment_group = "Team Acme"
I tried it but didn't work. Thank you in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2020 08:37 PM
Hi,
Check below script.
var gr = new GlideRecord('incident');
gr.addQuery('number','INC0010111');
gr.query();
while(gr.next()){
var str_value=gr.description;
gs.print(str_value);
gr.assignment_group.setDisplayValue(str_value);
gr.update();
}
Result -
Note - Make sure your string value should be present in Group table.
Mark correct/helpful based on impact.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 07:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 07:15 AM
Actually you are storing description in the str_value [first red box] and then setting that value to assignment group [second red box] thats why it not able to find any reference in the reference field and unable to set the field value. See below screenshot.
If you have assignment group name in the Description field then this would work.
Please mark this helpful if it answered your question.
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:10 AM
Hi,
As I already mention as note. You can only set value to reference if that value already present in table, otherwise not.
I can see you have entered "Unable to access" this value is not present in group table(means non of the group having name like that);
var str_value=gr.description; ?? this will copy value from description field
gs.print(str_value); // this will give info massage of description field value
gr.assignment_group.setDisplayValue(str_value); // this will set value to assignment group if description field value is name of one of the group in Group table.
Mark correct/helpful based on impact.
Thanks,
Dhananjay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 11:46 AM
Thank you!