Reset workflow for REQ and RITM and Approvals

shaik23
Tera Expert

Hi all,

I have a below requirement.

When the state is “Closed Skipped” or “Closed Incomplete,” and the Parent REQ is closed,  mark it as active, set the state to “Pending Approval,” in REQ restart the workflow, set the RITM state to 1, activate it, restart the associated flow, and add a work note indicating the request has been restarted by the 'current user'.

its a UI action i have written a code the states of REQ and RITM is changing and worknotes getting updated but the Approvals set to cancelled, in approvals i found the worknotes as RITM workflow restarted but the workflow didn't reset.

shaik23_0-1723180770496.png

 

 

 

 

 

 

 

 

 

 

 

 

 

var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();

if (req.next()) { 
    if (req.request_state == 'closed_incomplete' || req.request_state == 'closed_skipped') {
        req.setWorkflow(false);  
        req.active = true;
        req.request_state = 'requested'; 
        req.update();
        gs.info('Parent request state updated to Requested');

        new Workflow().cancel(current);
        new WorkflowApprovalUtils().cancelAll(current, "Workflow and approvals reset as part of request restart.");

     
        current.active = true;
        current.state = '1'; 
        current.update();

    
        new Workflow().restartWorkflow(current);
        gs.info('Workflow restarted for RITM: ' + current.sys_id);

      
        current.work_notes = 'Request has been restarted by ' + gs.getUserDisplayName();
        current.update();
    }
}


action.setRedirectURL(current);

 

 

 

 

 

 

 

 

 

 

 

 

 



REQ:

shaik23_1-1723180850190.png

 

RITM:
worknotes and approvals

shaik23_0-1723181149140.png

 

Approval:

shaik23_3-1723181017004.png

 

REQ workflow :

shaik23_0-1723199198121.png

we have flow designer for RITM

shaik23_0-1723213253416.png

 


pls assist me to resolve this

@Ankur Bawiskar @Dr Atul G- LNG @Allen Andreas @Anurag Tripathi @Jaspal Singh @Community Alums 

 

1 REPLY 1

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @shaik23 

 

I have a below requirement.

When the state is “Closed Skipped” or “Closed Incomplete,” and the Parent REQ is closed,  mark it as active,

Atul: When REQ is closed, and you want to mark is Active true, it is a pure violation of the process and foundation principles of ITIL. Highly NOT RECOMMENDED.

 

 

set the state to “Pending Approval,” in REQ restart the workflow, set the RITM state to 1, activate it, restart the associated flow, and add a work note indicating the request has been restarted by the 'current user'.

Atul: As above, RITM once close is closed, dont reopen or restart. You are increasing technical debt.

its a UI action i have written a code the states of REQ and RITM is changing and worknotes getting updated but the Approvals set to cancelled, in approvals i found the worknotes as RITM workflow restarted but the workflow didn't reset.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************