Automatically assign Project Lead for 'High' priority issues
Goal | When an issue is created with a specific Priority value, automatically assign it. |
|---|---|
Scenario | You want to automatically assign any high-priority issues to your Project Lead. The Project Lead can review the issue for accuracy and then reassign it as necessary. High-priority issues could have a specific Priority value or use custom fields to designate them. |
Components | |
Baseline |
|
You are viewing the documentation for Jira Cloud.
Requirements
Jira Administrator login
Live Fields for Jira Cloud
You need to determine which Priority value or values will trigger automatic assignment.
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:
// Check if the current issue's priority is set to "High"
if (getFieldById("priority").getValue()?.name === "High") {
const context = await getContext();
const { extension: { project } } = context;
// Fetch details of the current project using its ID or key
const projectDetails = await JiraApi.ProjectsService.getProject({ projectIdOrKey: project.id });
// Get the project lead information from the project details
const projectLead = projectDetails.lead;
// If a matching user is found, set them as the assignee
if (projectLead) {
getFieldById("assignee").setValue(projectLead.accountId);
} else {
logger.warn(`Project lead not found. Assignee not set.`);
}
}Click Save.
Check the boxes for On load and 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 issue with a Priority value of ‘High’ and verifying that the issue is assigned to the correct user.
Congratulations!
You can now automatically assign an issue based on the value of a field!