Change Workflow - Adding Condition to Approval - User

shane_davis
Tera Expert

I was looking at the article from "http://wiki.servicenow.com/index.php?title=Custom_Transitions_for_the_Approval_-_User_Activity" because I wanted a third condition called More Information Required on the Approval - User object in my workflow. I've added the condition and performed all the steps in the Wiki article.

What I want is for the State under the Approvers tab on the Change to change FROM Requested TO Information Required which I've added AND to progress the workflow as shown in the screenshots. Unfortunately, I am getting the two scenarios below.

When the script below is added to Approval - User, the State remains Requested and the workflow progresses as needed...called Script 1 in the screenshots. Only issue here is that I want the state to change as mentioned above.
if(approvalIDs && approvalIDs['more']) {
answer = 'more';
} else if (counts.approved > 0) {
answer = 'approved';
} else if (counts.rejected >0) {
answer = 'rejected';
}


When the script below is added in place of Script 1 above, the State change, but I get an error in the workflow.... called Script 2 in the screenshots
if (counts.approved > 0) { answer = 'approved'; }
else (counts.rejected> 0) { answer = 'rejected'; }
else { answer = 'more'; }


I've added some screenshots to help show what I am talking about. In short, I am trying to have an option in the workflow to ask the submitter for more information rather than approving/rejecting the Change Request. I am new and finding this difficult to do, but will appreciate any help!

10 REPLIES 10

Gerald Harris
Kilo Contributor

I am working with the same requirements. If there is anyone who can help with this one it would help me as well.


shane_davis
Tera Expert

I finally have it working the way I want it to, but not exactly like the article mentioned above. In short, with each approval in the workflow, my approver can choose Approve, Reject, or More Information Required.
- Choosing Approve sets the approval state to approved and proceeds the workflow.
- Choosing Reject rejects and ends the workflow
- Choosing More Information Required sets the approval state to More Information Required and pauses the workflow at that approval. I have a notification outside of the workflow that sends an email (in my case) to the Change Request "submitted by" telling them to add more information. Once the submitted by has added more information, they manually get with their manager, and when the manager changes the state to Approved from MIR, the workflow proceeds.

Perform the steps below to make it work like above.
In the Wiki article....
1. Complete "2.1 Task 1: Add a State to the User Approval Form "....all 8 steps

2. Complete "2.2 Task 2: Add a Business Rule to React to the State Change "....all steps

3. Do NOT perform step 2.3 Task 3

4. Do NOT perform step 2.4 Task 4....I wait for anyone to approve and reject when anyone rejects instead of the script mentioned in this step.

5. Look at Wiki article "Notification - Information from separate table" and run the background script from that article. Be sure to paste YOUR SysID in the script where mentioned.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(function(){
var gr = new GlideRecord("sysevent_email_action");
if (gr.get("SYS_ID OF YOUR EMAIL NOTIFICATION")) {
gr.recipient_fields = "sysapproval.ref_change_request.u_submitted_by";
gr.update();
}
})();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6. Create the notification per the 3 screenshots with whatever conditions you want. Mine emails the person who submitted the change. I had to run the background script above because the approval state MIR is on the sysapprover_approval table whereas the notification needs to email the submitter and contain info from the change_request table.


Hope this helps! - Shane






Hi Shane,



Thanks for the steps to implement adding a new option in the approvals. One question - did you create a BR on 'sysevent_email_action' to trigger the notification as every time you cannot run a background script if the approval state changes to 'More information required', correct ?



Your thoughts please ?


Suhas,



        The background script was ran once simply telling the system the u_submitted_by field is not on the Task table (sysapproval is a reference field to Task), but on the Change Request extended table.   However, looking back now, I am not exactly sure why I needed that since my notification is already on the change_request table.   Therefore, the notification is triggered when the change_request.state is More Information Required per the screenshots I attached.



Shane