Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Component Lead in post function

Jens January 29, 2021

Hello,

Is there any way how to set Component Lead for a specific project in a post function in a workflow ?

My idea or use case is, that I have to choose IT Technician, who is supposed to be on duty, so I would like him to be set as Component Lead in project "IT Support" (IS) for Components ABC and XYZ, and tickets are automatically assigned to Component Lead, so all issues are assigned to him. I do not want to set him manually to Component Lead role, I want to have it automatized (imagine adding different Technician to 10 Components every day). My idea is that I will create a ticket and set him as Assignee and in Post function for Create issue will be configured that Assignee will be set as Component Lead for specified Components, but I do not know how to do that. I'm able to use add-ons ScriptRunner and JWT.

Thank you very much for your help!

BR, JJ.

2 answers

0 votes
Nic Brough -Adaptavist-
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.
January 29, 2021

With Scriptrunner, what did you try?

I'd start from something that probably includes lines like

  • import com.atlassian.jira.pageobjects.project.components
  • issue.getComponents()
  • component.setLead( <user> )

But obviously, I don't know how you are choosing the user to set or where you're getting the component from.

Jens February 1, 2021

Hi Nic,

Thank you very much for your reply. Unfortunately I'm a total newbie in using ScriptRunner, so I do not know how to write a functional script :-(

My use case is:

  • I have project IT Support (IS) and this project has multiple Components: AD, Cisco, Other and more
  • I create a ticket to this project and assign it to someone, let's say the username of the Assignee is jan.jenik
  • I need to change the Component Lead in this project for Components AD, Cisco and Other to Assignee of the ticket, so in this case jan.jenik

So it is not about Components in the ticket, but about components in the Project and its Component Leads. Maybe this can be done other way, but I do not know how..

I do not know how to write the exact code, it should be like:

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByName("IT Support")
def components = project.getComponents().findByName("AD" OR "Cisco" OR "Other")
def newLead = getCurrentIssueAssignee()

components.setLead(newLead)

I do not know how to figure out the part getCurrentIssue Assignee and how to set Component Lead somehow like component.setLead() it just does not show me any option to set it. Also project.getComponents().findByName("AD" OR "Cisco" OR "Other") cannot have OR and multiple strings in brackets.

I hope it is understandable.

Thanks, JJ.

Nic Brough -Adaptavist-
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.
February 1, 2021

Assuming this is being done in a post function, then issue.getAssignee() will get you the assignee,

In your script, components is set to a list of components, not a single one, you will need to iterate over that list, setting each element's lead individually.  Or do it one at a time, with three findbyname statement which should give you a single component directly.  I've only every findbyname with single items.

0 votes
Frank Leclerc _Decadis AG_
Contributor
January 29, 2021

Hi Jan,

with JWT it is unfortunately not possible to set the component lead via PostFunction.
I can already imagine that this can work with ScriptRunner, but I haven't found an example in a hurry.
A workaround with JWT could be that you use project properties.
You can set them via PostFunction and then set the assignee in the workflow equal to the responsible person from the project property.
If this should be an option for you, here is a link to our documentation:

Set or create JWT project property 
Use project property in JWT expression 

If you have any further questions, please feel free to create a ticket in our JWT Service Desk.

I hope this helps you further.

Cheers,
Frank

Jens January 29, 2021

Hi Frank,

Thank you very much for your reply. I tried to do it using ScriptRunner, but I was not successful. So I hope that someone could advise :-)

Anyway thanks a lot for the idea with project property, I will try that ;-)

BR, Jan

Frank Leclerc _Decadis AG_
Contributor
January 29, 2021

Hi Jan,

if we can support you with the implementation with JWT, don't hesitate to create a ticket at our support.
That's what we are here for.

Have a nice weekend,
Frank

Like Jens likes this

Suggest an answer

Log in or Sign up to answer