how to copy the fied values from RITM and create a new record automatticaly

surya76
Tera Contributor

whenever an RITM is created i need to create a record in my custom table ("CASE FILING ");

how to achieve this using Business rule.

Here RITM is getting created with 4 variables , with the values of these variables i must able to create a record in case filing table . how to achieve this 

image

how to automate this whenever an RITM is created it should automatticaly create a record in my case filing table?

 

 

Thanks

6 REPLIES 6

Corey16
Tera Contributor

I just answered this here . 

 

https://community.servicenow.com/community?id=community_question&sys_id=fcdb523adb058914bb4a474d139619cd

Corey16
Tera Contributor

Maybe I'm old fashion but I would do this in a workflow. 

  1. Create a workflow that has at least a script activity to generate this new record. 
  2. Go to the catalog item and select this newly created workflow . 

To reference the variables you would use current.variables.YOURVARIABLENAME

So in the workflow you can have a script activity that looks like 

var gr = new GlideRecord('case_filing');
gr.initialize();
gr.mydummyvar = current.variables.mydummyvar;
gr.insert();

 

After this on each requested item if it were to ever error out you have a link to it from that ritm at the bottom left under related links called 'Show Workflow'. You can also control the state and other things based on the creation of this new record. Hope this helps. 

Saurav11
Kilo Patron
Kilo Patron

Hello,

Please write an after insert business rule on RITM table and then use the below script:-

 var inci = new GlideRecord('Custom_table');

inci.initialize();

inci.short_description = current.short_description; //do this for other fields.

//if you want to copy work notes and comments, then you can try this

inci.work_notes = current.work_notes.getJournalEntry(-1); inci.comments = current.comments.getJournalEntry(-1); inci.insert();

action.setRedirectURL(inci);

 

Please mark answer correct/helpful based on Impact.

Corey16
Tera Contributor

I suggest not doing this as a business rule and would strongly encourage you to use a workflow or flow designer.