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.

Copy Related Record to New Record

bburdick
Mega Guru

Basically, I am wanting to be able to copy all of the field attributes from one record into a new record, yet substitute just a few.

Rather than specifically call out every field such as the following:


current.assigned_to = producer.assigned_to;


I would like to just rather do a while loop where I could say something like this:


while(array.length > 0 ) {
current.array[x] = producer.array[x];
}


Any suggestions on what that coding would be? I am not sure how to get the fields in the array. I have done something simliar with catalog items where I declared all the variables on a form, but how do I get all the fields in a record?
6 REPLIES 6

bburdick
Mega Guru

Tony, that is awesome! Thank you so much for your insight and help!


Jehiellb
Giga Contributor

Hi guys,

 

I know this is an old post.. This maybe out of the context but just want ask how can I add all the related records when copying a change? 

currently only Affected CIsImpacted Services/CIs, and Change Tasks are able to be copied over to new change.

find_real_file.png

Any idea how can I achieve this? I tried editing the 'Copy Change' UI Action but I failed, nothing happens.
any suggestions what else should I change to make this work? I'm gonna be honest, I'm not that good when it comes to scripting  BUT I'm trying. Maybe you guys can help me with that too. 🙂

 

Just in case you came across with this question, your help will be much appreciated, Thank you in advance!