how to copy the fied values from RITM and create a new record automatticaly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 05:32 AM
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
how to automate this whenever an RITM is created it should automatticaly create a record in my case filing table?
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 05:34 AM
I just answered this here .
https://community.servicenow.com/community?id=community_question&sys_id=fcdb523adb058914bb4a474d139619cd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 05:34 AM
Maybe I'm old fashion but I would do this in a workflow.
- Create a workflow that has at least a script activity to generate this new record.
- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 06:01 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 06:08 AM
I suggest not doing this as a business rule and would strongly encourage you to use a workflow or flow designer.