Forums

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

Script runner: Creating sub-tasks condition not working due to special character

Graciela Persch Severo August 8, 2019

Hi all!

I need to create a sub task only when a custom field has a certain value, I read a lot here regarding Script Runner and Conditions and I managed to get mine to work using: cfValues["Team"]*.value.contains('Team Central') || ('Team Other') 

BUT! On the production system, the teams have "-" on the name. Team-Central, Team-Other, in this case, the condition cfValues["Team"]*.value.contains('Team-Central') || ('Team-Other') doesn't work and it creates sub-tasks for all other teams.

I have no idea how to make the script read the team name correctly if it is having issues with the special character :( unfortunately, changing the field value is not possible in this case.

I also tried ('Team-Central') || ('Team-Other') in cfValues["Team"]*.value and changed double quotes for single quotes and so on, the condition is not being applied.

 

thank you in advance :)

Graci

1 answer

1 accepted

1 vote
Answer accepted
Ilya Turov
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.
August 8, 2019

what's the type of your custumfield? if it's multiselect then try this:

('Team-Other' in cfValues["Team"]*.value) || ('Team-Central' in cfValues["Team"]*.value)

if single select:

cfValues["Team"]?.value in ["Team-Other", "Team-Central"]

I believe it should work

Graciela Persch Severo August 8, 2019

Hi Ilya! It works! I am using multiple choice, forgot to mention.

Thank you so much for the really quick response and for solving my problem :))))

Have a great day!

Graciela Persch Severo August 12, 2019

Hey @Ilya Turov , do you know how to avoid linking this sub-task to the epic of the US/Bug? The reporter doesn't want it to be linked and show up on the epic issues :|

Thanks

Ilya Turov
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.
August 13, 2019

you can add to your validator something like

&& !(issue.issueType.name in ["Bug", "Epic"]) 

basically, name all the issuetypes you want to avoid

i believe, there is something like this in builtin examples, cant check atm

Graciela Persch Severo August 13, 2019

actually, he wants the sub-task to be created for US and Bug, I have added the post-function on both Workflows and this is working perfectly, but the sub-tasks are showing on the Epic linked issues and he doesn't want the sub-tasks linked there.

Here is how it is right now:

CaptureAWS.JPG

 

Since the sub-tasks (named "Merge") are like dummy tasks, they don't want it to be linked to the epic. That works when they create the US without an Epic Link and only link the epic afterwards, but they want to use the epic link when opening a ticket...

I googled it and everyone wants sub-tasks to be linked on Epics, this guy wants things the other way around :P

Suggest an answer

Log in or Sign up to answer