The CreatorCon Call for Content is officially open! Get started here.

Second approval depending on Input ?

Andy Pickles
Tera Contributor

Hi guys and girls ..

I have a workflow, that requests approval, and then creates a catalog task if approval is granted.

But i have been asked to include more functionality ..

Basically, if the first approver approves, but then decides that this also needs looking at by another department, we then want approval sent to the second set of approvers with notes.

 

Im struggling to think of a way to achieve this . Ideally there would be a check box somewhere on the first approvers form? that if checked, then it would be sent to the second set of approvers (with their comments), but if not checked then workflow would go straight to the creation of the catalog task.

 

There must be a way to do this but it is not obvious to me . Can any of you splendid experts suggest something i should look into please?

Thanks so much

25 REPLIES 25

Hi andy,

You can Use an IF condition between both approval activities and define the conditions on basis of the input values from user.

shloke04
Kilo Patron

Hi @Andy Pickles 

My suggestion here would be as below and you should be able to achieve your requirement:

1) Instead of creating a field on Approval Table, my suggestion here is to create a New Variable and say Name it as "Second Approver".

Navigate to your Catalog Item and create a Reference Type variable as per details below:

New Variable Details:

Name: Second Approver

Type : Reference

Reference table: User(sys_user)

Once this variable is created second step will be as below:

2) Create a Catalog UI Policy and hide this variable only on Catalog Form and Catalog task Item View using the checkbox "Apply on Catalog Item View and Apply on Catalog Task" as shown below:

find_real_file.png

So using this Catalog UI Policy you will be able to hide this variable from form and Task and will be shown only on RITM form.

3) Now the third and last component, modification to your Workflow:

a) So your workflow will look like below say after your First Approval activity, use a IF block and validate if there is any value in New Variable which has been created above, if the response is Yes then generate the Approval to next level else proceed with the current flow as shown below:

find_real_file.png

So the IF block checks for the Second approval selected by the first approver or not. So sharing the Code for each activity as below:

IF Block code:

answer = ifScript();
function ifScript(){
	var checkApproverPresent = current.variables.VariableName; // Replace "VariableName" with the new Variable which has been created
	if(JSUtil.notNil(checkApproverPresent)){
		workflow.scratchpad.Approver = checkApproverPresent;
		workflow.scratchpad.getComments = getComment(current.sys_id);
		return 'yes';
	}else{
		return 'no';
	}
}

function getComment(ritmID){
	var gr = new GlideRecord('sysapproval_approver');
	gr.addQuery('sysapproval',ritmID);
	gr.orderByDesc('sys_created_on');
	gr.setLimit(1);
	gr.query();
	if(gr.next()){
		return gr.comments.getJournalEntry(1).toString();
	}
	
}

Second Approver Record Script :

var answer = [];
answer.push(workflow.scratchpad.Approver);

This should work for you. let me know if you are stuck.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shloke

I suggested the same approach but instead of coming to RITM and checking the box, Approver can just click a button and the variable value sets to true.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

@Rohila Voona Ohh okay, my bad I did not went through all the responses . Agree can be done either way.

Have shared the detailed steps as well which I thought might be useful for the author to avoid any confusion.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thankyou for detailed explanation,It sure helps the author. 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP