How to impose a JIRA transition restriction depending on the value of a drop-down custom field.

Vasanta Kumaar
Contributor
June 13, 2023

Hi All,

 

We are planning to restrict the transition of JIRA issues based on the Single Select Custom field Value.

We have a Single select drop-down field which has two values.

  • If the custom field Value  is  option A:
    • following users can transition the ticket:
      • Admins
      • Assignee assigned to that ticket
      • Reporter assigned to that ticket
  • If the custom field Value  is  option B:
    • only Admins can transition the ticket

Could you please let me know How to implement the above scenario.

 

Thanks,

Vasantakumaar.

 

2 answers

0 votes
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.
June 14, 2023

Hi @Vasanta Kumaar

You can do this in two ways, either using the Validator or Behaviour.

The Validator can be used to validate if the required fields are filled else the transition will fail.

A similar function can also be done using the Behaviour.

Below is an example using the Validator:-

1) Select the Simple Scripted Validator

simple_scripted_validator.png

2) Add a condition in the conditions field along with the error message that will be returned.

validator_config.png

3) Below is the sample code used for the validator:-

def loggedInUser = Users.loggedInUser

def adminGroup = Groups.getByName('jira-administrators')

def softwareGroup = Groups.getByName('jira-software-users')

cfValues['List2'].value == 'Option1' && (adminGroup.members.contains(loggedInUser) || softwareGroup.members.contains(loggedInUser))

Please note that the sample code above is not 100% exact to your environment. Hence, you will need to modify it accordingly.

 

When using the Validator, the validation takes place after the transition button is clicked, as shown below:-

test1.png

I hope this helps to answer your question. :-)

Thank you and Kind regards,

Ram

Vasanta Kumaar
Contributor
June 14, 2023

Hi Ram,

Thanks for the response.

But my request is completely different.

Based on the Custom field value in the single select field, I need to allow certain users to transition from one status to another status. 

I have only two values in Custom field Option A & B.

  • If the custom field Value  is  option A:
    • following users can transition the ticket:
      • Admins
      • Assignee assigned to that ticket
      • Reporter assigned to that ticket
  • If the custom field Value  is  option B:
    • only Admins can transition the ticket    

Thanks,

Vasantakumaar

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2023

Hi,

It seems that you will have to use a script in your workflow validator or condition.

Vasanta Kumaar
Contributor
June 16, 2023

Hi Mohamed,

 

Could you please provide let me know which validator or condition I need to use and any sample script available.

 

Thanks,

Vasantakumaar

 

Suggest an answer

Log in or Sign up to answer