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?
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.