Workflow or BR for Release to be moved to 'Awaiting Approval' when Change is raised/attached to it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:56 AM
Hi, I need help with creating a flow designer or business rule for this scenario:
Release record cannot be moved to 'Awaiting Approval' state unless a Change Request is attached or raised under it.
I've been trying to figure out how to do it using Flow Designer but it seems like I am just running around in circles.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 08:11 AM
And additional, once Change is raised/attached to the Release record, it has to be approved first before the Release can be approved by the Release admin approver.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 08:46 AM
So I created this BR, but even if the Change has been raised already it still cannot move to another State. Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 09:35 AM
Hello @tindiz ,
Please give a try to the script below and let me know how it works for you.
(function executeRule(current, previous /*null when async*/) {
// Check if the state is changing to 'Awaiting Approval' or other relevant states
if (current.state == 'awaiting_approval' || current.state == 'work_in_progress' || current.state == 'testing_qa' || current.state == 'deploy_launch') {
// Check if there is a related Change Request
var changeRequest = new GlideRecord('change_request');
changeRequest.addQuery('release', current.sys_id);
changeRequest.query();
if (!changeRequest.hasNext()) {
// No Change Request found, prevent state change
current.setAbortAction(true);
gs.addErrorMessage('Release cannot move to the selected state without a Change Request.');
} else {
// Change Request found, check if it is approved
if (changeRequest.approval == 'approved') {
// Change Request is approved, allow state change
// Add any additional actions as needed
} else {
// Change Request not approved, prevent state change
current.setAbortAction(true);
gs.addErrorMessage('Release cannot be approved until the associated Change Request is approved.');
}
}
}
})(current, previous);
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 09:50 AM
It did not work. When I try to move the state to 'Awaiting Approval' OR 'Work In Progress' OR 'Testing/QA' OR 'Deploy/Launch it is not giving the error message even though a Change Request is not raised under the Release it just pushes through with the state change.