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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can you help me set approvers basis two custom fields in jira?

Hi,

At the time of issue creation if a category (single select custom field) has a value selected 'xxx' then the issue must go to ND approval. ND approvers are different for different countries. Let say country (multi select custom field) is selected as 'yyy' then approver is the user 'abc' and if the country selected is 'zzz' then the approver is the user 'efg' etc. There is a list for this.

I want write a custom script for this and set it as Post function on that respective transition. 

Please help me fix this.

1 answer

1 accepted

1 vote
Answer accepted

That's possible, but you'll have to keep your country/user association right in the script.

 

Something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption


def countryUserMap = [
countryName1:user1,
countryName2:user2,
//etc
]
def categoryCf =ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Category').first()
def countryCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Country').first()
def category =(issue.getCustomFieldValue(categoryCf) as LasyLoadedOption).value
def country = (issue.getCustomFieldValue(countryCf) as LasyLoadedOption).value
if(category == 'xxx){
def assignee = ComponentAccessor.userManager.getUserByName(countryUserMap[country])
issue.assignee = assignee
}

Hey Peter,

Will try this , thanks.

Hi Peter,

Thanks for solution, that really worked for me.

Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

47 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you