Skip to content

Instantly share code, notes, and snippets.

@icerge
Created November 4, 2020 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save icerge/c1abf48e279e8e9cea7a44c006f631ad to your computer and use it in GitHub Desktop.
Save icerge/c1abf48e279e8e9cea7a44c006f631ad to your computer and use it in GitHub Desktop.
ServiceNow - Approval types

Approval types

Requirement justification

We had a very similar requirement due to the multiple number of different approvals needed for our Change process to be able to display an Approval Type to our approvals. We were able to accomplish this by performing the following configurations:

Technical design

  1. Add a column to the Approval table [sysapproval_approval]. For our solution we simply added a Choice type column called Approval Type [u_type]. We then created the choices we needed in the Choices related list.
  2. Next we modified the Workflow Activity Definitions for each of the Approval Workflow Activities. You can find these by searching for Workflow Activity Definitions in the navigator. For example, open the Approval - User definition record. Scroll down to the Activity Variables tab and click the New button to add a new variable. This will seem very familiar if you have created Catalog variables. For our solution our variable was created with the following attributes:
  • Column name = u_approval_type
  • Label = Approval Type
  • Type = Choice
  • Order = Enter the appropriate Order number to place your new variable field where you want it to be displayed on the Approval Activity screen when you are configuring it within a Workflow.
  • Max Length = 40 (This needs to match the length you created the column on the Approval table, can be larger if needed)
  • Choice = Dropdown with -- None --
  1. We tried to use the Choice table but it didn't recognize our choice field on the Approval table to automatically pull in the same choice values we created on the Approval Type column in the Approval Table. Instead we ended up manually creating the same values on the Variables Choice List (seems to be Fuji related issue, it was fine in Orlando).
  2. Once you have the variable added and configured you have to add one simple line to the Script. Locate this function:
  • _createNewApproval: function(userId, state, approvalOrder)
  1. Add the following line to the script right before the return approval.insert(); line in the function, should be last line in function.

Alternatives

  1. Use business rules in Approval table to populate field based on scripted decision or in case of Approval - Group activity.
  2. Use a script field in Approval - User activity to define the approval type and evaluate script contents in activity definition script (same method as in 4).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment