"Create a sub-task" post-function script is not behaving properly

I am running JIRA version 6.3.12.

When a new issue gets created, I am trying to use two separate consecutive Post Functions in my workflow to automatically create subtasks if a condition is true and assign subtask to appropriate users. I am using script post-function to create these subtasks based on what Franchise Name was selected and assign the sub-task to different users. "Franchise Name" is a custom field that is a pull-down list. When an issue is created and the script runs, what I get is regardless of what Franchise Name is selected, always 2 subtasks get created. Any help will be really appreciated. 

-------------------------------------------------------------------

Here is what I have for the first post-function"

condition:

cfValues['Franchise Name']?.value == 'FRANCHISE A' || 'FRANCHISE B' || 'FRANCHISE C'

target issue type:

Sub-task

Additional issue actions: 

issue.summary = ('Franchise was selected:  ' + issue.summary)
issue.assigneeId = 'usernameA@email.com'

-------------------------------------------------------------------

Here is what I have for the second post-function

condition:

cfValues['Franchise Name']?.value == 'FRANCHISE AA' || 'FRANCHISE BB' || 'FRANCHISE CC'

target issue type:

Sub-task

Additional issue actions: 

issue.summary = ('Franchise was selected:  ' + issue.summary)
issue.assigneeId = 'usernameB@email.com'

----------------------------------------------------------------------

2 answers

First thing is your conditions: What type of custom field is your 'Franchise Name' ?

(if your custom field is a multi-select field it shoul be as follow : 

cfValues["Some Multiselect"]*.value.contains("Some value")

 

for the rest, the format should be as follow: 

issue.summary = 'Franchise was selected:  ' + issue.summary()
issue.assigneeId = 'username'

Thank you for your response. The custom field is a "Select List (single choice)". I was playing around with it more and got it working using this condition statement:

(cfValues['Franchise Name']?.value == 'FRANCHISE AA') || (cfValues['Franchise Name']?.value == 'FRANCHISE BB') || (cfValues['Franchise Name']?.value == 'FRANCHISE CC')



Excellent ! Good job ! fyi i added the tag "script runner" to your issue.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

111 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you