Add specific Organization to ticket automatically Edited

Hi - 

Currently I'm using a script post-function to add some specific users as Request Participants to a specific type of issue. I'd like to switch that over to use an organization.

 

I was reading

https://community.atlassian.com/t5/JIRA-questions/auto-add-organization-on-creation-of-ticket/qaq-p/25440

but that seems more aimed at adding ALL organizations applicable, and only when the ticket is created via JIRA, not the SD portal.

 

I have two scenarios that I'd need to address with this issue:

 

1) Add a specific organization upon the creation (via portal) of a ticket in X type

2) Add a specific organization upon the creation (via portal) of a ticket in X type in which a custom field is flagged in a specific way.

 

Can anyone point me in the right direction on this? Thanks!

1 answer

Hey Kevin,

You can follow the example in the documentation and if you want to get a specific one then you will need to slightly change the last lines to 

def organizationsToAdd = organizationService.getOrganizations(currentUser, organizationsQuery)?.right()?.get()?.results?.find {it.name == "Organization A"}

// get the Organizations custom field
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Organizations")

// finally update the organizations custom field

cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), [organizationsToAdd]), new DefaultIssueChangeHolder())

kind regards, Thanos

 

states cannot cast to java.util.Collection

@Thanos Batagiannis [Adaptavist]the real problem came into play when trying to set multiple orgs.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

85 views 0 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you