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

Murthy Ch
Giga Sage

Hi @Samiksha2 

You can achieve this by writing after insert/update BR on target table.

Have you tried anything?

Thanks,
Murthy

Yes I tried,

var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);

var gr = GlideRecord('sn_gf_goal');
gr.addQuery('name', current.goal);

gr.query();
if (gr.next()) {
gr.u_se_bu.setValue(a);
gr.update();
}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

how will you determine which record in Goal to update? any reference field on Goal which refers Target table?

what script did you try so far and where are you stuck?

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

var a = current.u_bu.getDisplayValue();
gs.addInfoMessage(a);

var gr = GlideRecord('sn_gf_goal');
gr.addQuery('name', current.goal);

gr.query();
if (gr.next()) {
gr.u_se_bu.setValue(a);
gr.update();
}