RITM CI should be duplicate to SCTASK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi ,
Good Day.!
Requirement is :
whatever the CI am selecting when submitting in RITM, that same CI should be duplicate / auto reflect to SCTASK also.
Screenshot can't post, sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
how are you creating sc_task?
Via workflow or via Flow
OR
you can create before insert BR on sc_task table
Condition: current.request_item.cat_item.name == 'Your Item Name Here'
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var ritm = current.request_item.getRefRecord();
current.cmdb_ci = ritm.variables.variableName; // give your variable name here
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Thanks for reply.
I am not using any flow or workflow,
my RITM is taking table configuration_ci and SCTASK is taking cmdb_ci table. does it work?
I had already tried with same BR but no luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
CI is variable or field on RITM?
If CI is some variable on your catalog item then my BR will work which is shared above
If you want CI from RITM form field to be used then update line as this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var ritm = current.request_item.getRefRecord();
current.cmdb_ci = ritm.configuration_item;
})(current, previous);
If you want whenever RITM CI changes the change should happen on SC Task then use this
1) after update BR on RITM table
2) condition: CI field changes
3) Script
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.sys_id);
gr.query();
while (gr.next()) {
gr.cmdb_ci = current.configuration_item;
gr.update();
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
You can use a business rule to achieve your goal. Defined on the sc_req_item table, see below.
The following script in the 'Advanced tab:
(function executeRule(current, previous /*null when async*/) {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.cmdb_ci = current.cmdb_ci;
sctask.update();
}
})(current, previous);