Can we set a custom field as mandatory based on other custom field value ?
For example - "Work Around" customfield should be set as mandatory for "NON Blocker" value of Criticality Customfield but NOT for "Blocker" value of Criticality Customfield
For your info -
Criticality field value - 11131
Non-Blocker Value - 11305
Blocker Value - 11306
Work Around field value - 11134
Also please note - both the fields are in diferent screen. Criticalit field is in create issue screen and Workaround field is in next transition screen
Please provide us the configuration code if required as I am not expert in developing Jira codes
Regards
Sumit Mitra
You can do this, but it requires:
Here is a high level explanation so you can get an idea of what is needed.
After the issue is created, we are going to create a second transition with the same name and screen, and have it go to the exact same status. In effect, we're going to create a transition where the Workaround field is required, and a duplicate transition where it is not. And, we are going to use the Conditions to hide one of the 2 transition buttons based on the value of what is entered in the Criticality custom field.
How To:
Because you did't list the status or transition names, I'm just going to use [ Create -> Open -> In Progress ] for this example. For the transition name, I'm going to simply call it "Start".
Steps:
We just did 2 things
Please note that setting a field as required through the Validator transition does not display a required asterisk, but it is actually required.
We have followed your above mentioned steps. But after configuring this both the transitions were hide for Blocker and Non-Blocker Criticality values.
I am explaining our requirements again -
We have configured two workflow transtion in aparticular workflow.
1) production incident occurred
2) Initial analysis started
We have a customfield in "production incident occurred" transition namely "Critical" and the field ID is 11131. There are 2 values in this field namely "Blocker" and "Non-Blocke". The value ID of "Blocker" is 11306 and value ID of "Non-Blocker" is 11305.
Now we have a custom field namely "Work Around" in "Initial Analysis started" transition. The field id is 11134
We need to set "Work Around" field required in "Initial Analysis started" transtion if anyone choose "Non-Blocker" from "Criticality" field in "production incident occurred" transition and if anyone choose "Blocker" from "Criticality" field in "production incident occurred" transtion then "Work Around" field should be optional in "Initial analysis Started" transtion.
For this purpose I have configured Behaviour script for "Work Around" field. Please find the script below -
FormField priField = getFieldById("customfield_11131") FormField priJustField = getFieldById("customfield_11134") String Criticality = (String) priField.getFormValue() if (Criticality == "11306") { // 11306 is Blocker priJustField.setRequired(false) } else{ priJustField.setRequired(true) }
But after configuring the above code both "Work Around" field set required for both "Non-Blocker" and "Blocker" value. Could you please inform if anything wrong in my code or we need to use any alternative way
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
I have a working code to set Behaviour on a parent field and based on the field values other field can be marked as mandatory or not at time of creating issue.
def childField = getFieldByName("XYZ") def parentField = getFieldById(getFieldChanged()) def selectedOption = parentField.getValue() as String if ((selectedOption == "abc") || (selectedOption == "def") || (selectedOption == "123") || (selectedOption == "111")) { childField.setRequired(true) } else { childField.setRequired(false) }
Hope this helps
Regards
Chander Inguva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Inguva, Thank you for your help. I have some confusion - My parent field name is "Call Type". In this field there is a value namely "New Machine Required". If I choose "New Machine Required" Value from parent field "Call Type" the child field namely "Instance Type" should be marked as mandatory. I can not able to understand how can put those values in your script. Could you please update your script with the values which I have mentioned ? Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Chander,
Did you add it as a validation script or initializer script? did you add this to the parent field or child field? Or did you add it to the workflow action?
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.
Hi @David G, @Nic Brough [Adaptavist]
we have almost similar issue.
In our case CustomFieldB is an cascading custom field that includes Option A and Option B, this Options has several Values. So we need CustomFieldA to be required, when CustomFieldB = OptionA.ValueB, while performing Close transition.
However we do not need this Close tranistion to be hidden. Therefore I didn't added the condition.
I have tried the simple script by adding cfValues['CustomFieldB'] == 'OptionA.ValueB' as a validation to the Close transition and additionally I have added "Field Required" Validator for CustomFieldA. But it doesn't work.
When I'm performing "Close" transition the CustomFieldA is required as CustomFieldB is set up to OptionA.ValueB, but when the CustomFieldA is filled, it still askes me to fill it in. Why ? How can I fix it ?
THanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, is it possible to achieve that by writing the groovy script??? I am also facing this issue but it would be nicer if we can achieve this by a script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This issue is solved by using Condition "Value Field". I have create 2 different transtion as you suggested and add "Criticality" value "Non-Blocker" and Set "Work around" as required in One Transition and "Criticality" value "Blocker" in another Transition. After that problem is resolved
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.