How do I update component field using post functions in a transition?

Ryan Thomas October 10, 2013

I have the JIRA Utilities Suite installed and there are two options but neither offer Component as an update field:

1. Update Issue Custom Field:Updates an issue custom field to a given value.

2. Update Issue Field:Updates a simple issue field to a given value.

Is this a problem with my Component field type or is Component not able to be edited using Post Functions?

Specifically, I want all issues of a single type to be assigned into a specific Component.

5 answers

1 accepted

1 vote
Answer accepted
Ryan Thomas October 15, 2013

Short answer would be no.

@All Thanks for all the suggestions. In the basic install of OnDemand with JIRA Utilities Suite, We are not able to update Component(s) field as a post function (which seems like a no brainer).

To update the Component(s) field as a transition Post Function, I have two options:

  1. Install Bob's plugin: https://bobswift.atlassian.net/wiki/display/CW for $300 for this one workflow, which I can't justify to my company.
  2. Write a custom Post Function, which will require updates and maintenance if ever I or another producer want to add the ability in the workflow.

    Neither option seems streamlined or long term. I'll go request it be a field added to the JIRA Utilities Suite.

Again, thanks @All for the suggestions!

14 votes
Ovidiu Vasilescu March 16, 2015

2 years later I encountered this problem and here is my solution / hack for whoever else finds this topic on Google:

  1. Create a Custom Field (I used "Components Hack") with a dropdown that has the same options as your  Component/s. Don't need to add it to any screens.
  2. Add a Post Function on transition to Update Custom Field (Components Hack) to Audio or whatever you need
  3. Add another Post Function to "Copy Value from Field to Field" and copy the value from Components Hack to Component/s

 

It's dirty but it works smile

 

EDIT 4 years later: This workaround is still "helping" people. For the love of your sanity though, if you can, please use a more elegant solution that doesn't make you maintain a separate custom field for no apparent reason.

 

1. JMWE now supports updating the Component/s field on transition and is a great app overall, I definitely recommend it.

2. Create a custom Scriptrunner script to run on transition. Scriptrunner I see as absolutely vital for JIRA, so I assume everyone has it. Example code to set the component:

 

import com.atlassian.jira.component.ComponentAccessor
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
projectComponentManager.findAllForProject(issue.projectObject.id)
def component = projectComponentManager.findByComponentName(issue.projectObject.id, "YOUR COMPONENT HERE")
issue.setComponent([component])

 

Sadek Joma'a August 20, 2015

Thanks, this workaround does work. You have to be careful to use a select list not a regular text field because it wouldn't work that way.

Matt Briede May 29, 2019

Thanks! Not a 'clean' solution, you're right, but this worked for me.

Janusz Lenar January 16, 2020

@Sadek Joma'a As of today, the workaround using Single-line text field works as well, FYI.

Guy Armitage February 8, 2021

This is the best solution so far, you could also create an automation to update the issue - but it's also a massive overhead

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
October 10, 2013

Conditioned Workflow Functions for JIRA has a post function for updating issues including components.

0 votes
RambanamP
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.
October 10, 2013

the best way is write a postfunction using java syntax or using script runner plugin

https://jamieechlin.atlassian.net/wiki/display/GRV/Script+Runner

another way is by using javascript you can set default value for component!

0 votes
Bharadwaj Jannu
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.
October 10, 2013

Suggest an answer

Log in or Sign up to answer