How to script approvals based on multiple values in a Service Catalog resource question

How to script approvals based on multiple values in a Service Catalog resource question

I am really stuck on trying to use a Python script to automate our approval process.  I have focused on the script that Gopinath published, but cannot get it to evaluate values in Service Catalog questions, or fields with multiple values.  There seem to be a lot of conversations around this topic, and is a critical need for us to automate.  My challenge is that I am not a Python programmer, and don't know what data is available in the JSON file to have the scripts evaluate.

 

Hopefully I am just missing something, and can get this script working.  If not, are there any options to get this behavior corrected in ServiceDesk?  I want to avoid having to use another third party solution to just process ticket approvals.

 

Here is what our situation is:

 

  • Each application has an approver assigned by the company.  These are called Data Stewards.
  • When someone requests an application, they select it in a Service Catalog form, from a resource question.  A requester can select multiple applications.
  • When an application is selected, certain fields are then made visible for the requester to fill out application-specific details.
  • When an application form is submitted, I compile all of the form information into the description field for easier organization.  This includes listing the Data Steward in the description.  The format is "Data Steward:  Dave Barrante"

 

What now currently happens is that a Help Desk person needs to manually create the approvals for the listed Data Stewards, and send them in stages.  They need to manually copy the information into the approval notification, so the Data Steward can see what the approval request is for (they have problems clicking links and looking at the ticket details).  It also needs to be done this way in case any Data Steward rejects an approval; we cannot have this impact all other Data Steward approvals.

-If we submit them all under one stage, then only one Data Steward can approve\reject.  All other Data Stewards after that cannot.

-If we submit them in stages, then all Data Stewards can vote, but it is done serially, not in parallel.  This means that the Data Stewards in Stages 2,3,4,5 won't receive notification until the first Data Steward votes.

I am really hoping that this can be changed in the product soon, because it is a severe hindrance to an otherwise great feature.

 

 

My strategy to work around this, was to use python scripts in this article: 

https://forums.manageengine.com/topic/script-master-3-how-to-implement-a-dynamic-request-approval-mechanism-through-custom-triggers-with-configurable-csv-file

 

I set it up, and created a sample field with approval codes in the form.  That works very well, but here is the brick wall for me: 

Since the form itself is not 'application specific', I need the script to be able to evaluate multiple values of the resource question (This is where the requester is selecting which applications they need).  If python cannot check the values in a multi-value resource question in the Service Catalog, then option 2 would be to have python check for values within the description that match "Data Steward:  Dave Barrante", then create stages of approvals based on the unique Data Stewards.  A Data Steward may be listed multiple times, but only need to have one approval for that ticket from each Data Steward.  To assist with another limitation of not being able to script the application details into the outbound approval message, I have the approval notification message send the entire contents of the description to the Data Steward.

 

I wanted to just show what we are trying to do, and determine if it is possible through scripting.  In short, here is the ask:

 

  1. Use the script listed above to evaluate multiple values in a resources question. The example would be:  "If requester selected App#1, App#5, or App#7, then set Dave Barrante for Stage 1 approval.  If requester selected App#2, App#3, or App #9, then set Joe Sample as the next available Stage"
  1. Use the script listed above to evaluate the form description field for keywords (i.e. "Data Steward:  Dave Barrante"), and perform the same type of staging as in item #1.  This would also need to support multiple values and multiple approvers.
  1. Be able to set ServiceDesk to not treat all approvals in a ticket as a single approval.  It should be similar to a survey function, where the approval mechanism just collects feedback from the approvers and doesn't impact the ticket status, or the other approvers in a ticket.  Each approver needs the ability to approve\reject immediately after the ticket is submitted, and even after another approver performs their actions.

                  New to ADSelfService Plus?