Hello,
I have several transition cycle and for each a set of subtasks have to be completed, therefore a transition must not be performed if any of their related subtasks is pending.
I have tried several syntaxes but none is working.
Using CustomFieldName
issue.subtasks.filter(subtask => subtask.issueType.name == 'TypeOfSubTasks' && subtask.issueType.TypeOfActivity.value == 'ABC' && subtask.status.name != 'Closed').length == 0
Using CustomFiled ID
issue.subtasks.filter(subtask => subtask.issueType.name == 'Sub Test Execution' && subtask.issueType.customfield_5555.value == 'ABC' && subtask.status.name != 'Closed').length == 0
I set this in the workflow as VALIDATOR selecting ScriptRunner Script
I will appreciate any help to implement this control to the workflow.
Thank you in advance.
Enrique
Hi @Enrique ,
I think you are already there. Just remove the issueType on second condition:
issue.subtasks.filter(subtask => subtask.issueType.name == 'Sub Test Execution' && subtask.customfield_5555.value == 'ABC' && subtask.status.name != 'Closed').length == 0
Hi @Salih Tuç
Thank you for responding,
If I removed that condition, the validation would be considering all possible subtasks created for that parent ticket, and we have several. Therefore I have to limit my control to a sub-set of subtasks.
The intention is to prevent the transition of the parent ticket if there is any subtask of that type with that particular value in the customfield_5555 that is not closed.
Regards
Enrique
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, but I didn't mention that one :) Please take a look at the condition that I share and at the question (second one in question).
In the question, you are accessing the customfield through issueType, which is not correct. You are already checking if the issue is Sub-task, but you need to use directly "subtask.customfield..." in order to access the custom field value, instead of "subtask.issueType.customfield..."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Salih Tuç
This is what I tried:
Original:
issue.subtasks.filter(subtask => subtask.issueType.name == 'Sub Test Execution' && subtask.issueType.customfield_5555.value == 'ABC' && subtask.status.name != 'Closed').length == 0
Following your recommendation I changed it to:
issue.subtasks.filter(subtask => subtask.issueType.name == 'Sub Test Execution' && subtask..customfield_5555.value == 'ABC' && subtask.status.name != 'Closed').length == 0
Since that did not work I tried replacing the customfield_5555 reference for the actual field name, which I needed to change because the name had spaces so I replaced " " for "_" underscores
issue.subtasks.filter(subtask => subtask.issueType.name == 'Sub Test Execution' && subtask..Sub_Test_Execution_type.value == 'ABC' && subtask.status.name != 'Closed').length == 0
None of this worked. I wonder if there anyway to debug this code, for example if "
subtask.issueType.customfield_5555.value" is an invalid syntax or I am referencing something that does not exist and that level, is there a log where this error is stored?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Enrique,
Thank you for reaching out on the Atlassian Community.
If you find that you are still facing issues, we actually recommend reaching out to ScriptRunner support directly.
Here is a link to ScriptRunner on our Atlassian Marketplace, and here is a direct link to their support page.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Enrique
If you want to learn Jira expressions through examples, I can suggest trying the app our team developed —Workflow Building Blocks for Jira. It includes wizard-like validators, such as the Linked Issues Validator. With just a few clicks, you can create a validator based on a Jira expression.
What might interest you is that each validator displays a Jira Expression Preview panel, which helps you learn the syntax. Later, you can build your own validator using our Jira Expression Validator, which features an autocomplete function to assist with syntax and custom field IDs.
I hope it will help.
Cheers
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.