How I can Bypass Change Approval?

Naveen63
Tera Contributor

How I can Bypass Change Approval?

Requirement: I have one user named “Change Master” when he/she click on “Close Change” (custom btn). Change automatically goes to “Closed” state.(bypass all the approvals)

Any ideas would be greatly appreciated.

 

1 ACCEPTED SOLUTION

Pranay Tiwari
Kilo Guru

Hi Naveen,

You need to write your UI Action as below..

 

var gr = new GlideRecord("change_request");
gr.addQuery("sys_id",current.sys_id);
gr.query();
if (gr.next()) {
	gr.setValue("short_description","close");
	gr.setValue("state",3);
	gr.update();
	
	action.setRedirectURL (current) ;
	
}

 

My concept is,when you click on close change button then state=closed && short description=close,as i mention.

Now what you do with Workflow...

1st you need to create one workflow condition as below..,

 

 

and transition it to the END.

To achieve this you need to write Approval script, there you will check approval is approved or not and one more condition if(current.short_description=="close"){

answer="close"}

 

so whenever you click on close change ,the short_description will be "close " by UI action.

and the close condition meet so we connect approval close to END(connect every close node(IN APPROVAL ACTIVITY) to END) ,so when ever close condition meet workflow will END, AND Skip all approval.

 

Hope you will understand the logic.

 

Mark correct or helpful if it helps you.

 

Warm Regards,

Pranay Tiwari

| www.DxSherpa.com | pranay.tiwari@dxsherpa.com |

View solution in original post

9 REPLIES 9

Nitesh Balusu
Giga Guru

In your change workflow you can probably add an if statement before the approval activities, 

 

var a=gs.getUserID();

if(a=='change master')

return 'yes';

else 

return 'no';

 

if its a yes, you can probably direct it to your set values, set the values and end the change. 

if its a no, then just continue with whatever happens as usual.

Naveen63
Tera Contributor

Hi Nitesh,

Thank you for replying.

But I have some queries.


For example:- I have Change CHG1001(Authorize state), CHG1002(Scheduled state), CHG1003(Implement State) and CHG1004(New State).

Change Manager login in ServiceNow and click CHG 1001 request and click the “Close Change”(custom button) button after that change automatically “Closed” state
Again Change Manager Click CHG1002 request and click the custom close button so change automatically “Closed” state.
And so on…


But your solution is working on when the change request is in always “New” state (particular state).

Harsh Vardhan
Giga Patron

the solution which has proposed from nitesh will work to skip the approval make sure you passed the sysid of that user because gs.getUserID() will give you the logged in user id.

but here you are asking about the  Close Change”(custom button) functionality, what exactly you want ? according to you what should it be?

Naveen63
Tera Contributor

Hi Harshvardhan,

 

Actually, I am unable to change anything in the directly OOTB workflow so PFA of paint file where I can show my requirement and solution which was provided by Nitesh.

 

If I am using gs.getUserID() function in my workflow in if activity and in change workflow have four approval activity so It's not possible, I will use 4 times If activity to bypass my approval activity.

 

My Requirement: If I am login as a change manager in SNow one custom button showing in the banner.

A change request in any state like Access, Authorize etc when to Change manager login and click on Custom Close button, change directly in Closed state.