(Jira Server) After issue creation, post-function for auto-assignment based on component conditions

Sedanur Ozturk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 28, 2024

Hello,

I use JIRA Server v7.12.3.

For a specific issue type (bug) workflow,

I'd like to assign an issue to component lead on initial issue creation. But there are 2 conditions:

1. For some components it is ok to assign component lead.

2. However, for some components I'd like to assign one single user. (This user is not a component lead - here is the problem)

How can I do that by using post function on workflow transition configuration (ex: via Custom Script Post-Function) If script runner is the only way, could you please assist to write it in a simple way? 

 

P.S: I do not want to do this auto-assignment operation by only using Component Lead function. Because it executes for all issue types. I'd like to do for a specific issue type workflow. 

 

Thanks in advance!

 

2 answers

1 accepted

0 votes
Answer accepted
Laurie Sciutti
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 1, 2024

Hi @Sedanur Ozturk and welcome to the Community!  Have you thought about using an automation rule rather than a post-function script? 

Sedanur Ozturk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 2, 2024

Hi @Laurie Sciutti , thank you for welcoming :)

I'm not system admin and need to run some procedures for adding Automation app. And I'm not sure if this app is compatible or not. So that'd be the last option for me for now. 

Thanks indeed!

1 vote
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 8, 2024

Hi @Sedanur Ozturk - welcome to the community,

should be possible with a custom script in post function. Does the issue type you would like to apply this have its own workflow? Or is it a shared workflow for several issue types?

Best
Stefan

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 8, 2024

See a first pitch of such a script below. This is just a draft for you to figure out the elements and steps that could lead to your solution. 

Furthermore I always took the first component (as an issue could possible consist of more than 1 components).

 



import com.atlassian.jira.event.type.EventDispatchOption

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.component.ComponentAccessor





def issueManager = ComponentAccessor.getComponent(IssueManager)

def cfManager = ComponentAccessor.getComponent(CustomFieldManager)





def leadUser = issue.components.getAt(0).lead

def issueComponent = issue.components.getAt(0)






log.warn issue.issueTypeId.equals("10000")

log.warn issue.components.getAt(0).name





if (issue.issueTypeId.equals("10000")) { // -- > ID of issueType - you need to change to the ID of your issueType

    if(issueComponent.name.equals("Component 1")){

        issue.setAssignee("<any user you want, either component lead or other ApplicationUserObject>")

        log.warn "juhuuu"

    }

    else if(issueComponent.name.equals("anyOtherComponent")){

        log.warn "here you go"

    }

    else{

        log.warn "nothing happens"

    }

}




issueManager.updateIssue(Users.loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)











Like Laurie Sciutti likes this

Suggest an answer

Log in or Sign up to answer