Script to copy all contents of a RITM to a new RITM

Shant Cancik
Tera Contributor

Is there an easy way to copy a RITM and all its variable values onto a new RITM with a new number? I'd like to create a new RITM and just change one variable. I'm currently creating a script to copy fields and variables one by one. Is there an easier solution?

7 REPLIES 7

Hey David,



Yeah I've been thinking this through and what I don't want to amend the workflow. We need separate RITM records made so what I'd like to do is use my scheduled job to submit a specific catalog item with variable choices I set up through the scheduled job's script. Is this possible to do?


Shant Cancik wrote:



Hey David,



Yeah I've been thinking this through and what I don't want to amend the workflow.


Any reason why not?


We need separate RITM records made


Any reason why?   I've not heard of Amazon creating a duplicate each time a customer places an order.


what I'd like to do is use my scheduled job to submit a specific catalog item with variable choices I set up through the scheduled job's script. Is this possible to do?


Yes.


But you may want to consider who the RITM is raised for (will they see a duplicate in "My Requested Items"?), and what happens when fulfillers see double the workload under "My Group Tasks".


antin_s
ServiceNow Employee
ServiceNow Employee

Hi Shant,



I would leave it to you decide if you want to create a duplicate or not. But below is an easy approach to create a copy of a GlideRecord.



var inc = new GlideRecord('incident');


inc.get('ef43c6d40a0a0b5700c77f9bf387afe3'); // Query the record to be copied


inc.state = 1; // Field to be updated


inc.insert(); // This creates a new record with all values from Original record plus 'state' value




Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin