ui action

rognomolta
Tera Contributor

When a Requested Item (RITM) is cancelled or rejected, it is often moved to a closed state (Closed Skipped or Closed Incomplete). Sometimes, there is a need to restart these items and their associated workflows. This process involves:

Creating a UI action that is available only when the RITM is in a specific state (Closed Skipped or Closed Incomplete).
Ensuring that only users with the catalog_admin role can see this UI action.

If Parent REQ is closed, mark as active and set state to Pending Approval. Restart workflow

Updating the state of the RITM and its parent REQ.
Restarting the associated workflow.
Adding a work note indicating that the request has been restarted by the current user.

2 REPLIES 2

Bhavya11
Kilo Patron

Hi @rognomolta ,

 

Please refer below link

https://www.servicenow.com/community/developer-forum/restart-workflow-from-ui-action/m-p/2249262/pag... 

 

 

Please mark helpful if it's really worthy for you.

 

Thanks,

BK

 

Rohit99
Mega Sage

Hi @rognomolta,

You may try with the following code and for accessibility you need to write the following condition in UI action.
Attaching screenshot for reference.

gs.hasRole("catalog_admin")&& (current.state == '3' || current.state == '4' || current.state =='7')  // this stating that user who has catalog_admin role and RITM state is in close complete, close incomplete, close skipped is able to see the button.

Script:

var gr = new GlideRecord('sc_request');
gr.addQuery('request',current.request);
gr.query();
if(gr.next())
{
gr.request_state = 'requested';
gr.update();
}
current.state = '1';
current.update();
 action.setRedirectURL(current);
 
 
And for Flow designer/Workflow you just need to change triggering condition, run when created and updated.

Rohit99_0-1723103353470.png

 

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi