- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 08:46 PM
Currently idea is getting close on closer of demand.
it should not get auto close when demand close if it has the open epic associated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 08:54 PM
Hi @Amit_H ,
This is oob functionality and controlled through one BR: Update Idea State on Close.
You need to adjust the code in this BR. add below code.
(function executeRule(current, previous /*null when async*/) {
// Check if there is an associated Demand
var demandGr = new GlideRecord('dmn_demand');
demandGr.addQuery('idea', current.sys_id);
demandGr.addQuery('state', '9');
demandGr.query();
while (demandGr.next()) {
// Check for open Epics related to the Demand
var epicGr = new GlideRecord('rm_epic');
epicGr.addQuery('demand', demandGr.sys_id); // Ensure 'demand' references the associated Demand
epicGr.addEncodedQuery('stateNOT IN3,4,6); // Look for open Epics
epicGr.query();
if (epicGr.hasNext()) {
gs.addErrorMessage('The Idea cannot be closed as it has associated Demands with open Epics.');
current.setAbortAction(true); // Prevent the Idea from being closed
break;
}else{
var idea = new GlideRecord("idea");
idea.get(current.idea);
idea.setValue('close_notes', gs.getMessage("Closing idea as the corresponding demand is closed"));
idea.setValue("state", 3);
idea.update();
}
}
})(current, previous);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 08:54 PM
Hi @Amit_H ,
This is oob functionality and controlled through one BR: Update Idea State on Close.
You need to adjust the code in this BR. add below code.
(function executeRule(current, previous /*null when async*/) {
// Check if there is an associated Demand
var demandGr = new GlideRecord('dmn_demand');
demandGr.addQuery('idea', current.sys_id);
demandGr.addQuery('state', '9');
demandGr.query();
while (demandGr.next()) {
// Check for open Epics related to the Demand
var epicGr = new GlideRecord('rm_epic');
epicGr.addQuery('demand', demandGr.sys_id); // Ensure 'demand' references the associated Demand
epicGr.addEncodedQuery('stateNOT IN3,4,6); // Look for open Epics
epicGr.query();
if (epicGr.hasNext()) {
gs.addErrorMessage('The Idea cannot be closed as it has associated Demands with open Epics.');
current.setAbortAction(true); // Prevent the Idea from being closed
break;
}else{
var idea = new GlideRecord("idea");
idea.get(current.idea);
idea.setValue('close_notes', gs.getMessage("Closing idea as the corresponding demand is closed"));
idea.setValue("state", 3);
idea.update();
}
}
})(current, previous);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 08:57 PM
did you check any OOB BR is doing that?
if it's some OOB BR then you can simply deactivate that.
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