Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to copy List field value from one table to a string field of another table

Samiksha2
Mega Sage

Hi,

 

I have created a list field(BU with options a,b,c,d) in the sn_gf_goal_target table. 

and another string field(Selected BU) in the sn_gf_goal table. 

I want to copy the value of List from the Target table to Goal table.

 

Suppose Goal table has 3 Target records(1,2,3), and 

1 is selected a,b 

2 is selected c,d

3 is selected a,d.

Then in the selected BU all a,b,c,d will populate

 

Thanks!

1 ACCEPTED SOLUTION

Hi,

then update as this

var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);
var gr = new GlideRecord('sn_gf_goal');
gr.addQuery('sys_id', current.goal);
gr.query();
if (gr.next()) {
gr.u_se_bu = gr.u_se_bu + ',' + a;
gr.update();
}

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

BR on Target table , run on after

BR script should be this

I assume goal field on Target table refers to Goal table

var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);
var gr = GlideRecord('sn_gf_goal');
gr.addQuery('sys_id', current.goal);
gr.query();
if (gr.next()) {
	gr.u_se_bu = a;
	gr.update();
}
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur, but value of BU is not populating in the Select Bu field.

u_se_bu field is of what type?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

string