To copy Select Box variable choice values to another table choice field

Servicenow12
Tera Contributor

To copy Select Box variable choice values to another table choice field ?

Below did not work for me , I wrote this in Workflow RunScript activity :

var gr = new GlideRecord('incident');

gr.initialize();
gr.assignment_group = current.variables.support_group.getDisplayValue();

gr.insert();
}

 

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello,

remove getdisplayValue() and try below

var gr = new GlideRecord('incident');

gr.initialize();
gr.assignment_group = current.variables.support_group;

gr.insert();
}

Hope this helps 

please mark my answer correct if this helps you

View solution in original post

10 REPLIES 10

Mohit Kaushik
Mega Sage
Mega Sage

Hi There,

1. You need a sys_id for Assignment group field, so you need to remove getDisplayValue() from your code.

2. What are you getting in current.variables.support_group, it should give you a valid sys_id of a group which can stored in your incident's assignment group.

Try below changes in your script if above things are correct:

var grInc = new GlideRecord('incident');

grInc.initialize();
grInc.assignment_group = current.variables.support_group;

grInc.insert();

 

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

 It just an example i gave i should have given for some other field .It is a choice field only both catalog item and incident table.

eg:

 

gr.status= current.variables.app_status.getDisplayValue();

Muhammad Khan
Mega Sage
Mega Sage

Hi,

You can also use this

var gr = new GlideRecord('incident');

gr.initialize();
gr.setDisplayValue('assignment_group', current.variables.support_group.getDisplayValue());

gr.insert();
//}

It is not updating the choice field in incident table

For choice values, use something like below.

gr.setValue('state', current.variables.state.toString());