Requesting Additional Information via Variables on System Approvals

Janel2
Mega Expert

The Crazy Question:

How can someone look at their approval and complete some fields and approve the request at the same time?


The Need:

We've been finding this need more and more often lately where Approvers need to complete some information on a Requested Item before approving the request (or during, however you want to look at it).   A user submits something, the approver reviews and completes a couple fields, approver approves.   Done.   I think that sounds simple enough, right?   Just tack on some bonus fields to a Requested Item and... but where will those bonus fields come from?   How will they be managed?   How on earth will a manager ever know they have extra fields to complete?!

The Example:

There is a Requested Item called "Submit a Shiny New CI".   The user completes the fields on the form and submits it.   The RITM goes to "CI Overlord Approval Group".   Bill, the head manager of CI Overlord Approvals, reviews the new CI request and is going to approve it, but part of his job is to tie a cost center number and load balance number to the CI.   Information that the user submitting wouldn't know.   Since Bill has amazing ServiceNow developers, there are two extra fields that appear on the Approval form, just for him and just for the one Requested Item; "Cost Center" and "Load Balancer".   All Bill needs to do is fill out the two fields and hit approve and those two fields do whatever it they need to do.   And everyone lived happily ever after.

The Attempts so far:

What our previous developers had been doing was adding fields to sc_task and sysapproval_approver, which is causing a train wreck with UI Policies and Client Scripts now and frankly, I rather leave those two as much OoB as possible.   An alternative suggestion was to have the Approver look at the RITM, update some fields at the bottom, return to the approval, then approve.   Yeah... not only is that an icky way of doing it, how many people will take that many hops to even do it?     Okay, that is just stupid and there has to be a better way.

The crazy idea:

Approval Blocks!  

Bear with me here, it is just an idea.   The big requirement is that it must be as dynamic as possible so we're not adding more and more client scripts and UI policies on approvals and sc_task.   I want all the things that are specific to a Request Item to be on the Request Item.   No more of this bleeding out into tasks and stuff.

Here is the nutty idea, is this even possible?   (yes, yes, lots of custom work, yes, yes)

  • On the request item,
    • Make a container start/end called "approval_block_start" and "approval_block_end".  
    • Plop in whatever variables you need to be completed after submission.   Give the variable name a prefix of like, ab_ or something obscure.
    • Hide it via UI policy as normal (if you even need to) on the Requested Item.
  • On the Approval form,
    • Have a section called "Variables" (or whatever want to call it).
    • onLoad, have a client script (or something) that queries the RITM that needs to be approved.   Have it look specifically for a variable called "approval_block_start".
    • If it exists on the request item, show the "Variables" section on the approval form.
    • Query everything between the start and end containers on the RITM.   I'm not sure how this would be possible, but that is where the "ab_" prefix would come in handy.   Query for all the things that start with "ab_".   Probably shove it into an array or something and push it onto the approval.
      • This keeps the variables to display down to per Requested Item.
    • Display those variables on the approval form in our "Variables" section.
    • Update the Approve/Reject buttons to shove our new variable data back into the RITM (unless it is pulling the variables directly from the RITM (like a reference), then yay for us).

Approver can now complete the variables/information they need to and approve or reject at the same time.   Plus we can now do it dynamically per request item!

We'll probably need to pull out email approvals though...   hmm...

So… impossible?   Better solution?

2 REPLIES 2

Community Alums
Not applicable

Dear Janel Hagstrom,,




On request item front it sounded cool. However ,One point to add : query between container start and end wouldn't be possible .We cannot avoid UI Policies and Client Scripts in either case.Yes,Lots of customization might make this possible




Regards,


Kirti


Kalaiarasan Pus
Giga Sage

Are these variables on the RITM that you want to see/edit on the approval record?



If yes, quite possible.. The easiest way would be to create a new related list that queries the variable mtom table.. This has a potential issue that might creep in future as the variables table is a huge one.



Another possibility is as suggested by you. Create a UI page that read and displays these variables and update them back once editing is done... You might consider adding a related link on the form that in turn call this UI page on click. This will save the form space.



But for all these things to happen, you need to have a good experienced developer Good luck !!