- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 07:25 AM
Hi,
In change request, there is already a related list of affected cis, there can be multiple affected cis in this related list.
I want to populate all those affected cis in related list of change task affected cis. These change tasks are getting populated in change request at implement state in related list 'Change Tasks'.
Note: I can already see a related list tab in change task for affected cis, as we do not want another related list tab for affected cis.
Please suggest a business rule for this as we do not want a new relationship !!!!!!
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 07:37 AM
Hi,
you can use this logic to link those affected Cis to Change task
BR: After Update on Change Request
Condition: State [Changes to] Implement
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec1 = new GlideRecord("change_task");
rec1.addQuery("change_request", current.getUniqueValue());
rec1.query();
while(rec1.next()){
var gr = new GlideRecord("task_ci");
gr.addQuery("task", current.getUniqueValue());
gr.query();
while(gr.next()) {
var rec = new GlideRecord("task_ci");
rec.initialize();
rec.task = rec1.getUniqueValue();
rec.ci_item = gr.ci_item;
rec.insert();
}
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 07:37 AM
Hi,
you can use this logic to link those affected Cis to Change task
BR: After Update on Change Request
Condition: State [Changes to] Implement
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec1 = new GlideRecord("change_task");
rec1.addQuery("change_request", current.getUniqueValue());
rec1.query();
while(rec1.next()){
var gr = new GlideRecord("task_ci");
gr.addQuery("task", current.getUniqueValue());
gr.query();
while(gr.next()) {
var rec = new GlideRecord("task_ci");
rec.initialize();
rec.task = rec1.getUniqueValue();
rec.ci_item = gr.ci_item;
rec.insert();
}
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 11:30 PM
Hi Ankur,
I tried with this script but it is not working. The related change task should have the same affected cis in their related list as it is in change request affected cis related list.
Could you please suggest what could be done.
We want the affected ci related list of both change request and related change task to be same, if 4 cis are attached to change request affected ci related list, same cis should get attached to change task affected ci related list.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 12:54 AM
Hi,
script will work fine
Where have you written that script and share your latest script and the screenshot of where have you written it? i.e. business rule etc
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 03:30 AM
I have done it through business rule.