- 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-02-2020 05:46 PM
Reference field require sys_id or Display value. I can see you have used 'database' group so in that case the display value is "Database" with capital D.
Best way is to take the sys_id of Data base group and try like this.
gr.assignment_group = 'SYS ID HERE';
if you want to use Display name then try this.
gr.assignment_group = 'Database';
Please mark this correct & 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-02-2020 07:42 PM
Hi Sharjeel,
var gr = new GlideRecord ('incident');
gr.addEncodedQuery('numberSTARTSWITHINC0009009');
gr.query();
if (gr.get('287ee6fea9fe198100ada7950d0b1b73')){
//Database group sys_id
gr.assignment_group.setDisplayValue('Database');
gr.update();
}
Could you take a look? Once again, thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 03:47 AM
Let's debug this. I have placed few logs lets run your fix script and see what you got in the logs.
var gr = new GlideRecord ('incident');
gr.addEncodedQuery('number=INC0009009');
gr.setLimit(1); // return only one record.
gr.query();
gs.info("SNOW DEV - " + gr.getRowCount());
if(gr.next()) {
gs.info("SNOW DEV - " + "record Found!");
gr.assignment_group.setDisplayValue('Database');
gr.update();
}
Select Proceed from the dialog box and share me the screenshot of logs you got once fix script executed completely.
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 05:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 06:04 AM
Wow! Happy Learning Sir.
Muhammad