Sync error while reading impact from Jira to SN

Originally asked by Andrew on 11 December 2020 (original question)


Hello.

New script is created in Jira and sent to SN.

Incoming sync in SN for impact field looked as below but it didn’t work:

incident.impact = replica.customFields."11406"?.value

So I did mapping for this field, so now it looks:

def impactMapping = [
// Jira issue impact <-> SNOW incident impact
"1 - High" : "1 - High",
"2 - Medium" : "2 - Medium",
"3 - Low" : "3 - Low"
]
def defaultImpact = "3 - Low"
def impactName = impactMapping[replica.customFields."11406"?.name] ?: defaultImpact // set default impact in case the proper impact could not be found
incident.impact = nodeHelper.getImpact(impactName) //It is line 54 mentioned below

But now is a sync error:

Script error for issue INC0010770. 
Details: No signature of method: services.node.hubobjects.NodeHelper.getImpact() 
is applicable for argument types: (String) values: [3 - Low] 
Possible solutions: getAt(java.lang.String), getProject(java.lang.String). 
Error line: Script815.groovy:54

Comments:

Levente Bedő commented on 25 April 2023

@Andrew you can check the script I’ve shared, it may work for you too.

Answer by Juan Grases on 11 December 2020

Hi!

There is no such method nodeHelper.getImpact, you can do:

incident.impact =impactName

Answer by Levente Bedő on 25 April 2023

Hi, we managed to make it work.

We’re working with Jira cloud, and we found two custom fields there, Urgency and Impact. We added these to the screen of the project we wanted to sync (check if it’s there already, it may be depending on the Jira flavour you are using for your project).

Since Exalate has deprecated setting the priority directly, we need to set these two values to get an ITIL conform prio.

Please note, that these Jira fields use a 4 value choice instead of the expected 3 value choice, so you must compromise and do the matching yourself (you can replace entity with incident in the script if you have to).

Our Jira works as a master instance, we don’t change these values in SN, so you will have to write these scripts yourself based on the ones I’m providing here, if you need a two-directional sync of these field values.

SN incoming

// Urgency sync
    def urgencyMapping = [
        // Jira issue urgency <-> Snow incident urgency
         "High":"1 - High",
         "Critical":"1 - High",
         "Medium":"2 - Medium",
         "Low":"3 - Low"
    ]
    def defaultUrgency = "3 - Low"
    def urgencyName     = urgencyMapping[replica.urgency.value] ?: defaultUrgency // set default urgency in case the proper urgency could not be found
    entity.urgencyValue = urgencyName

// Impact sync
def impactMapping = [
    // Jira issue impact <-> SNOW incident impact
    "1 - Critical":"1 - High",
    "2 - High":"1 - High",
    "3 - Medium":"2 - Medium",
    "4 - Low":"3 - Low"
    ]
def defaultImpact = "3 - Low"
def impactName = impactMapping[replica.impact.value] ?: defaultImpact // set default impact in case the proper impact could not be found
entity.impact = impactName

Jira cloud outgoing

replica.urgency = issue.Urgency
replica.impact  = issue.Impact

Please share your script if you find these useful.

BR, L


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.