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 do I copy one array (i.e. List) to another in a business rule?

Shane J
Tera Guru

I need to copy an array (List) from the Idea table to a new Project record that has another field setup exactly the same way.   A straight-up 'setValue' doesn't work.

23 REPLIES 23

I think I found the solution here:   Copying array by value in JavaScript - Stack Overflow



BR Script, array stuff in bold:



var proj = new GlideRecord('pm_project');



var newArray = current.source_field.slice();


proj.setValue("target_field", newArray);


Surabhi5
Kilo Contributor

Hi Shane,

I have a similar requirement and would really need some guidance on how i can achieve this.

I dont seem to be able to work out this one.

 

Regards,

Surabhi

Can you provide the details for what you're trying to do?  I can't do much with that.  😉

 

Surabhi5
Kilo Contributor

Hi Shane,

 

I have created a custom field "Impacted company" on risk form which is a list type field. I have not picked a reference tables as per the requirement and created 5 values in the dictionary entry. If i select a value in that field during risk creation, i want the same value to be copied or carry forwarded to acceptance task during its creation. Is there a way to achieve it? i am pretty new to scripting. tried business rule direct assignment functionality but that's not copying the values.(attached images for reference)

 

Any help would be really appreciated.

 

Thanks

Surabhi

If your Acceptance Task is a child of the Risk record, why not just show the 'Impacted Company' field from the parent on the child form?

 

Than you don't have to deal with copying these over.  Will that work instead, or do you really need the values copied over?