Hello,
We would like to set "Preliminary Estimate" field is required when we select "Epic Type" field as 'Product Innovation' (in drop down options, we have other value as Product Improvement).
To achieve this we are trying to use behaviour function and used below script and it's working fine during issue creation level.
const preliminaryEstimateField = getFieldById("customfield_10107");
const epicTypeField = getFieldById("customfield_12161");
if (epicTypeField.getValue().name == "Product Innovation") {
preliminaryEstimateField.setRequired(true);
} else {
preliminaryEstimateField.setRequired(false);
};
However, While creating issue I can choose 'Epic Type' as 'Product Improvement' so that I can skip Preliminary Estimate Field. After that I can open issue and Change the 'Epic Type' to 'Product Innovation' and here it's not asking to fill 'Preliminary Estimate' Filed as required. but we are expecting it must ask to fill 'Preliminary Estimate' field (during edit issue level also)
The above script is working fine during issue creation level but it's not performing during edit issue level.
Could someone help on this issue.
Note: " We are using Jira Cloud not Jira Server, Behaviour feature is now available for Jira cloud "
Thank you
Balaji
Since you need to set the Product Improvement field to required based on the option selected in the Epic Type field, the approach you are using will not work.
I suggest modifying your code to:-
const changedField = getChangeField();
const isRequired = changedField.getType().toString() == "com.atlassian.jira.plugin.system.customfieldtypes:select"
&& changedField.getName() == "Sample List"
&& changedField.getValue()["value"].toString() == "Option1"
getFieldById("customfield_10046").setRequired(isRequired);
Please note that the sample working code above is not 100% exact to your environment. Hence you will need to make the required modifications.
Below is a screenshot of the configuration:-
In the example above, only if Option1 is selected from Sample List will Sample List 2 be set to required. Else if any other option is selected from Sample List, Sample List 2 will not be required.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
Since your requirement is to set the Preliminary Estimate Field to required based on the option selected in the Epic Type Field, your approach is incorrect.
Instead, you should try something like this:-
const changedField = getChangeField();
const isRequired = changedField.getType().toString() == "com.atlassian.jira.plugin.system.customfieldtypes:select"
&& changedField.getName() == "Sample List"
&& changedField.getValue()["value"].toString() == "Option1"
getFieldById("customfield_10046").setRequired(isRequired);
Please note that the sample working code above is not 100% exact to your requirement. Hence, you will have to make the required modifications.
Below is a screenshot of the Behaviour configuration:-
For the sample case above, I am running the test on two single Select Lists, i.e. Sample List and Sample List 2.
Only if Option1 is selected from Sample List Sample List, 2 will be set to required. If any other option is selected from Sample List, Sample List 2 will not be set to required.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
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.