How to add approval on incident

Yaseen2
Mega Expert

Hello,

I'm new to servicenow

How can I add to the incident the caller's manger approval as a first step of approval before proceeding with incident solution, and if that could be done without the need to a create a workflow since I'm trying to keep the standard incident fulfillment process using business rules.

Many thanks

1 ACCEPTED SOLUTION

No with only one business rule you can achieve it.

your state is being requested in the approval table not in the incident. if manager is looking into his my approval his initial state is in requested.

Write After business rule on incident table. (make inactive the previous business rule and try with this one )

for testing: impersonate manager and check his approval that is being applying or not and check the state also

 

var apprvl= new GlideRecord('sysapproval_approver');
	apprvl.initialize();
	apprvl.approver=current.caller_id.manager;
	apprvl.sysapproval=current.sys_id;
	apprvl.state='requested';
	gs.addInfoMessage('approval success!!');
	apprvl.insert();
	gs.addInfoMessage('approval success!!');
	

View solution in original post

13 REPLIES 13

Hi yassen,

 

If you only need to give approval to the manager then from that script you don't need to write if condition. just write up to approval.insert and check the status of the incident i.e requested or not. Also add the log messages after 2 to 3 line of code so that you will get to know if its working or not.

if the log messages getting then your code for that line is working.

 

Regards,

Ashvini.k 

Hi 

Should i create a new business rule to set approval to requested when the state is new 

Thanks

No with only one business rule you can achieve it.

your state is being requested in the approval table not in the incident. if manager is looking into his my approval his initial state is in requested.

Write After business rule on incident table. (make inactive the previous business rule and try with this one )

for testing: impersonate manager and check his approval that is being applying or not and check the state also

 

var apprvl= new GlideRecord('sysapproval_approver');
	apprvl.initialize();
	apprvl.approver=current.caller_id.manager;
	apprvl.sysapproval=current.sys_id;
	apprvl.state='requested';
	gs.addInfoMessage('approval success!!');
	apprvl.insert();
	gs.addInfoMessage('approval success!!');
	

Hi Ashvini,

I'd like to thank you from the bottom of my heart, it worked many thanks again and again , but one thing please if the manager rejected the incident what will happen to the incident

Glad it worked well!!

If manager rejected approval then make the status of the incident as a closed or according to your requirement you can apply condition in if else condition (refer condition the code i have previously provided) and write condition as per your requirement for ex.  in if current.approval=='approved' then current.state='closed'

 

Please mark my answer as correct and close the thread, So that other could easily find the solution for the same.

 

Thank you,

Ashvini.k