Forums

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

Can I do a post function to map certain custom field values to a single field?

Amanda Wallace March 7, 2018

I want to create a custom field for "Content Type" that is of field type: checkboxes. When people select their content type, I would like to run a post function in my workflow to assign a component. So, for example, if content types "Digital Ad" or "Print Ad" are selected, I would like the post function to select the component "Advertising"

 

Is this possible?

1 answer

0 votes
Kyle Moseley
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.
March 7, 2018

Yes, this is possible.

For the checkbox, see Adam's answer: https://community.atlassian.com/t5/Jira-Core-questions/How-to-get-checkbox-value-with-scriptrunner-in-post-function/qaq-p/278604

For the component setting:

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor

// you will probably end up just using 'issue' as provided by the post function script
MutableIssue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("NPB-3")
def pId = issue.getProjectObject().getId()
def component = ComponentAccessor.getProjectComponentManager().findByComponentName(pId,"test")
issue.setComponent([component])

 

Then of course you will have to add in your logic. But this should get you started.

Amanda Wallace March 8, 2018

Thank you for your response.  I am a little confused. Do I have to write code to accomplish this? Is it not something I can do using the Jira configuration?

Kyle Moseley
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.
March 8, 2018

Yes, I believe so. The above example requires ScriptRunner for JIRA.

There could be other add-ons that can accomplish this but I'm not aware of them.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events