Forums

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

Validate that parent does not have a child when creating a child via a button

aviv_eldad
Contributor
November 20, 2022

Hi everyone, I am new in Scriptrunner and I will love your help.

I have an issue type A, and on the view screen there is a button to create issue type B. Issue type B is a child of issue type A. When creating issue type B, there is a select list field to fill.

What I need to do is: When the button to create issue B is clicked, and value is selected from the list, check in parent A if there is a child B with the selected value. If so, don’t allow to create this issue B, and an alert will pop up

I thought to create a behavior script, but I’m stuck on how to even get started. How to get the parent ID? How to know when the button is clicked, and value is selected?

 

Thank you for your time and help!

 

Aviv

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 20, 2022

Hi @aviv_eldad 

You can add a validator (Scripted (Groovy) Validator) on your workflow and enter a similar groovy script:

issue.parentObject.get("customfield_16950") == "Value 2"

 I used the above with JMWE where customfield_16950 is your single select field and the "Value 2" is the value you want to check it against. If the above expression is true, only then the workflow can proceed.

Place the above validator on the create screen of your subtask's workflow. Let me know if that works out for you!

aviv_eldad
Contributor
November 21, 2022

Thank you, I will try that!

TAGS
AUG Leaders

Atlassian Community Events