"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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,861 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot