Jon G Lind
ServiceNow Employee
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
17m ago
In the initial version of ReleaseOps a Deployment Request may end up in a terminal state such as Cancelled or Failed with no way to recover and start the process over. The workaround to solve this is to run the following script in Scripts - Background or create a UI Action like a form link on the Deployment Request form in the ReleaseOps scope.
NOTE: If running from a background script eliminate the first line and replace the second with something like:
const drSysId = '{sys_id_here}';
(function(){
action.setRedirectURL(current);
const drSysId = current.sys_id;
const dr = new GlideRecord("sn_releaseops_deployment_request");
dr.get(drSysId);
gs.info("Cancelling DR " + dr.number + " " + dr.short_description);
const pdc = new GlideRecord("sys_pd_context");
pdc.addQuery("input_record", drSysId);
pdc.query();
while(pdc.next()){
gs.info("Cancelling PD Context: " + pdc.getUniqueValue());
sn_playbook.PlaybookExperience.cancelPlaybook(pdc, "Resetting due to error");
}
gs.info("Update DR State");
dr.setWorkflow(false);
dr.state = ReleaseOpsConstants.DEPLOYMENT_REQUEST_STATES.DRAFT;
dr.update();
gs.addInfoMessage("Cancelled any running playbooks and set state back to Draft.");
})();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.