Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

In Service Desk Reporter is not the Approver/Reviewer

Andrews January 21, 2020

I'm looking at adding Approvals to my workflow. I DO NOT want the ticket reporter/creator to be the approver/Reviewer. What is the most efficient way to accomplish this?

Now the person that has entered the request (reporter), should not be the approver/Reviewer. In case they are the same, the request should not go to the approver.
The approvers are listed and chosen from a custom field (single select).

What is the groovy code/JSU/JMEW to create this validator?

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Andrews January 21, 2020

Hi @Thomas Schlegel , @JamieA 

How to achieve this via Script Runner Custom Validator? Could you please help me on this.

Andrews January 23, 2020

I achieved this through the JMWE plugin validator groovy script on the required transition.

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2020

Hi @Andrews 

Apologies for delay in response.

Script Runner's validator is able to handle this.

You will need to do some configuration as well.

1) Add a custom field -  for example a Single User Picker.  The Print Screen Below I've added the Approver field which is a Single User Picker.

custom_field.png 

2) Configure the workflow and set the approver.  In the print screen below, I'm choosing a In Progress and setting the Add Approval option.

configure_1.png

3) Next select the configuration and set the field in which you want to display the approvers. 

 

set_approver_field.png 

 

4) Once that is done, you will need to add a new validator into the transition.   To add the validator,  select Script Validator [ScriptRunner] -> Simple Scripted Validator

 

Below is a sample code that I have used

issue.reporter.username != cfValues["Approver"].username

 

The field that I am setting this for is the Approver field.  Below is a print screen of my configuration.

 

validator_config.png

 

So now, when I create a new issue for this project, if the Reporter and Approver are the same, the ticket will return a message and cannot be created.

 

Below is a print screen of the validation

validation_create.png

 

 

Hope this helps :)

Prasad Andrews January 30, 2020

Thank you, Ram.

 

But I achieved this through JMWE plugin validator.

Yogesh Mude
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.
September 2, 2020

@Ram Kumar Aravindakshan _Adaptavist_  Will this solution work on JSD portal??

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 2, 2020

Hi Yogesh,

To answer your question, yes it should work the same in the JSD portal.

Yogesh Mude
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.
September 3, 2020

Nope its not working

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 5, 2020

Hi @Yogesh Mude 

I have tested this on the JSD portal and it does work.  The only difference is the display of the error message. 

You will, however, need to make some changes to your configuration.

Go to the project.
1) Select the project's cog.
2) Next, select Request types.
3) Either add a new Request type or modify your existing Request type as shown below.

add_custom_field_for_sd.png

Make sure that the field you want to use is included in the Request Type as shown below:-

add_fields.png

 

Next, you will need to modify the workflow slightly.

As shown in the print screen below, you will need to add a validator for the create transition.

configure_validator_1.png

You can use the same example I provided in my earlier comment i.e.

issue.reporter.username != cfValues["Approver"].username

 

Once this is done you can start to test it. 

1) First login as shown below and select the project you want to use. In the example below I am logging in as an Admin user.

test_1.png

 

2) Next, create a sample ticket and select the approver as the same user you log in as.  In the print screen below, I have logged in as the Admin, and I have also selected the Admin as the approver.  When I try to create the ticket, the Error message is displayed.

test_2.png

3) Next, I try to create the ticket once again, but this time instead of selecting the Admin (logged in user) as the approver I have selected another user test_3.png

4) The ticket is created successfullytest_4.png

Hope this helps to answer your question :)

Jeno Fernando November 18, 2021

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

I have tried your solution and steps above but it still does not work for me. 

We have an "Approvers" field which is a user picker (multiple users). And I tried to insert this script as mentioned in your steps:

issue.reporter.username != cfValues["Approvers"].username

However during testing, it still does not work.

Capture.PNG

Jeffrey Chan July 4, 2023

Hi Jeno, I think in your case because you are using a multi-picker, your result will not be a single object, but a collection.  Hence the collection won't understand the username field.  You'd need to iterate over the collection to make sure none of them are the reporter, or do something like username not in approvers.  That's not actual syntax, mind you, just the concept.

TAGS
AUG Leaders

Atlassian Community Events