copy a string value to a reference field

Snow Dev5
Tera Contributor

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.

1 ACCEPTED SOLUTION

Dhananjay Pawar
Kilo Sage

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 -

find_real_file.png

 

Note - Make sure your string value should be present in Group table.

 

Mark correct/helpful based on impact.

Thanks,

Dhananjay.

View solution in original post

18 REPLIES 18

Hi @Snow Dev,  

Please mark the appropriate response as CORRECT. I think the solution provided by me worked fine for you and that is as per the question description if yes, kindly mark my response as correct so that others can referenced this. 

You cannot mark two answers correct at the same time 🙂

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Pratiksha Kalam
Kilo Sage

Hello,

Use this...

 

var str_value=current.string_field;

current.reference_field.setDisplayValue(str_value);

 

if answer is helpful please mark correct!

Thanks,

Pratiksha

 

My case, I'd like to assign the string value directly. I tested it, but didn't work. Thank you.

Virendra Mali
Mega Expert

Hello,find_real_file.png

if setDisplayValue not working then try gr.fieldname = "string value" which i use for caller_id,

if you are using string variable then use like

var str = "value"

gr.fieldname = str;

mark correct and helpful if it solve your query

Regards,

Virendra

Dhananjay Pawar
Kilo Sage

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 -

find_real_file.png

 

Note - Make sure your string value should be present in Group table.

 

Mark correct/helpful based on impact.

Thanks,

Dhananjay.