getPriority

    Signature

    Helper nodeHelper
    Signature getPriority (String priorityName) getPriority (String priorityName, issue)
    Description

    Returns a priority.

     Null if not found

    Returns a priority.

     Null if not found

    Introduced in 0.8 3.2.0

    For Jira Cloud and Jira Server 7.5.x and lower

    Example use

    if (replica.assignee.displayName == "Steve Jobs") {
       issue.priority = nodeHelper.getPriority("Critical")
    } 

    For JIRA Server 7.6 and higher

    In 7.6 version Atlassian introduced priority schemes, which helps to choose different properties for different projects. 

    We retrieve a project key from the issue variable to find a project with a set of priorities.

    Example use

    if (replica.assignee.displayName == "Steve Jobs") {
       issue.priority = nodeHelper.getPriority("Critical", issue)
    } 

    Mapping priorities

    // SETTINGS
    def priorityMapping = [
            "Remote Priority 1": "Local Priority 1"
    ] as Map<String, String>
    // END: SETTINGS
    
    def desiredPriority = priorityMapping[replica.priority.name] ?: replica.priority.name
    issue.priority = nodeHelper.getPriority(desiredPriority, issue)
    if (issue.priority == null) {
        throw new com.exalate.api.exception.IssueTrackerException("""
    Can not find priority `${desiredPriority}` for the project `${issue.project?.key}`.
    Please check project settings or change the script""".toString()
        )
    }

    For Freshdesk

    In Freshdesk, the getPriority method retrieves a priority based on its name. The possible priority values in Freshdesk are Low, Medium, High, and Urgent. If an invalid priority name is provided, both the ID and name will be set to null.

    For seamless synchronization between different systems, priority mapping can be used to align Freshdesk priorities with those from external platforms. For example, you can map external priority names to Freshdesk's supported values to ensure consistent issue handling.

    Example Usage in Freshdesk:

    • Basic Usage:

      entity.priority = nodeHelper.getPriority("Medium")
    • Priority Mapping from External Systems: Convert external priority names to Freshdesk's valid priorities. The key is the source side and the value is the destination side (Freshdesk).

      def priorityMapping = [ "Highest": "Urgent", "High": "High", "Medium": "Medium", "Low": "Low", "Lowest": "Low" ] entity.priority = nodeHelper.getPriority(priorityMapping[replica.priority?.name] ?: "Medium")