Using Insight for change approvals for a unique request type

Vincenzo Ciaravella April 7, 2022

Hi,

I've managed to configure an Insight Post Function to retrieve and add an Approver to a JSD ticket.  No problem there.

The challenge I have is that the Workflow is used by multiple "Request Types" and when I try to Isolate the Request Type to one particular JSD form via the Insight Post Function "Condition" (Groovy Script), it does not work.  All "Request Types" are assigned an Approver.  Not just the one stated in the "Condition".

Since the Insight "Condition" states that "Supported fields are Jira Text fields and Insight custom fields." I made sure to use the "text" CF field that we created ("Customer request type in text") for the "Customer Request Type".  We thought that the Groovy script would accomplish our specific need.  Unfortuantely not.  Below is the "Groovy" script used for the Insight Post Function "Condition"


import com.atlassian.jira.component.ComponentAccessor

def requestTypeCF = ComponentAccessor.customFieldManager.getCustomFieldObject(12581)
def customerRequestType = issue.getCustomFieldValue(requestTypeCF)
if ("si/58b854d5-eb32-297d-9a89-c43e293c19b9".equals(customerRequestType)) {
log.warn("true")
return true
}
log.warn("false")
return false

image.png

Any suggestion would be appreciated

Vince C

1 answer

0 votes
Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2022

Hi @Vincenzo Ciaravella 

The support for Insight & Text fields is specifically related to the 2 dropdown settings for the post function. In your condition, there's not difference in support.

You can simply use the ID for the actual request type field and then retrieve the value as text:


//Use the correct field ID (not the text field)
def requestTypeCF = ComponentAccessor.customFieldManager.getCustomFieldObject(12581)
issue.getCustomFieldValue(requestTypeCF).toString()

Let me know how that goes.

Kind regards
Jorden

Vincenzo Ciaravella April 12, 2022

Thanks for the reply Jorden,

The Insight Post Function worked fine the way I had originally configured it (works only when I used the scripted "Customer request type in text" field and not the regular custom field "Customer request type").

That unfortunately does not solve my real problem.  I wanted the Approval Buttons to appear in the customer portal and to do this I must use the "Add Approval" config that comes associated with each status.  This works if I don't discriminate which request type I use.  What I failed to realize is that this "Add Approval" and the "Insight Post Function" (which contains my condition on which request type will add an Insight "manager" to the "Approvers" custom Field) are complete mutually exclusive events.

I was hoping that they would work in concert with each other (adding the Approval Buttons based on the Insight Post Function).

All this to avoid having to set up a unique workflow (with approvals) for a specific Issue type (associated to one Customer request type).  That may be my only option.

Thanks again for your effort

Jorden Van Bogaert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 13, 2022

Hi @Vincenzo Ciaravella 

Ah sorry I misunderstood. Approvals is indeed tricky if you want them only on some request types. In that regard, I think you're indeed restricted and have to use multiple workflows.

I believe approvals work with conditions on the transition, perhaps you can also change the condition to have either the approval or a custom condition to validate the request type again. In case the request type is different from the one you require approval for, your condition should return true so the transition button becomes available to your team without having approve/decline buttons.

However, not exactly sure if that's going to work (and if I even remember correctly how it works).

Vincenzo Ciaravella April 22, 2022

Thanks for taking the time to answer.  Much appreciated!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events