Enable 'Priority' options based on issue type
Goal | Enable and disable specific options for the field Priority based on the issue type. |
|---|---|
Scenario | You want to provide two different sets of values for the Priority field and make only one set of options visible based on the value for Issue type. For example, you want to use a specific set of values for Bugs, and another set for all other issue types. |
Components | |
Baseline |
|
You are viewing the documentation for Jira Cloud.
Requirements
Jira Administrator login
Live Fields for Jira Cloud
Your instance must include values for the Priority field that only apply to specific issue types - for example, “Critical” is only available for Bugs.
Create the live fields configuration
For Screens, select Issue create view, Issue view, and Issue transition view.
Click Projects, and then click Select projects in the right-hand panel.
Select the project or projects to which your configuration should be applied.
Click Issue types, and then click Select issue types in the right-hand panel.
Select the issue types to which your configuration should be applied (for example, Story and Task).
Under THEN, click Add Scripted action, and then click Start scripting in the right-hand panel.
Enter the following script:
// Enable or disable the "Priority" field based on the selected issue type
/**
* Fetch a priority by name.
* @param {string} priorityName - The name of the priority to search for.
* @returns {Promise<JiraApi.Priority | null>}
*/
const getPriority = async (priorityName: string): Promise<JiraApi.Priority | null> => {
const priority = await JiraApi.IssuePrioritiesService.searchPriorities({ priorityName });
return priority.values[0] || null;
};
// Get the current issue type
const issueType = getFieldById("issuetype").getValue();
//Get the Priority values
const criticalPriority = await getPriority("Critical");
const highestPriority = await getPriority("Highest");
const highPriority = await getPriority("High");
const mediumPriority = await getPriority("Medium");
const lowPriority = await getPriority("Low");
// Show the "Priority" field only if the issue type is "Bug"
if (issueType?.name === "Bug") {
getFieldById("priority").setOptionsVisibility([
criticalPriority.id,
highPriority.id,
mediumPriority.id],
true);
getFieldById("priority").setOptionsVisibility([highestPriority.id, lowPriority.id], false);
} else {
getFieldById("priority").setOptionsVisibility([criticalPriority.id], false);
getFieldById("priority").setOptionsVisibility([
highestPriority.id,
highPriority.id,
mediumPriority.id,
lowPriority.id],
true);
}Click Save.
Check the box for On change to set the configuration to trigger only when the issue is updated.
Click Save.
Enable and test your configuration
Your configuration is now complete. Verify that the configuration is enabled on the Live Fields administration page. Once it’s enabled, you can test it by creating a new Bug; verify that only the correct options are available for Priority. Then, create another new issue of any other issue type and verify the Priority values.
Congratulations!
You can now use different sets of options for a single select or multi-select field based on the value of another field!