1
0
-1

State Mapping.xlsx


Hi Everyone,


I am working on Jira to snow integration and I am facing below challenges,Please help me out with these.


  1. Field mapping : In order to map fields like Priority and Severity. We have different values in Jira and SNOW for these fields. I tried to map the values with below example but its not working:

 

Map<String, String> priorityMapping = ["1 - High": "High", "1 - Critical": "Critical"]

if (replica.priority.name in priorityMapping.keySet()) {
   def priority = nodeHelper.getPriority(priorityMapping[replica.priority.name])
   issue.setPriority(priority)



  1. Status Mapping: We have a requirement where we want to update the values of snow and Jira fields depending on issue status in Jira as described in sheet below.  I tried something like this but I am not sure about syntax.

 

if (replica.status.name == "Canceled") {
    if (replica.customFields."Cancellation Notes"?.value == "Canceled by Client") {
        incident.customFields."Close Code"?.value  = "Not Solved"
    }
}
 
 
 
if (replica.status.name == "resolved") {
    issue.customFields."YourCustomFieldName"?.value = "value"


  1. Sync Panel In snow: I wanted to check with you that do we have a way to show jira issue link in snow ? the way we see it in sync status panel in jira.


  1. Francis Martens (Exalate)

     I tried to map the values with below example but its not working:

    What is not working?

  2. Anshuman Bakshi

    When i am mapping priority values it is not syncing the values from SNOW to Jira. Also do you have any feedback on Status Mapping and Status Panel in SNOW.

CommentAdd your comment...

4 answers

  1.  
    1
    0
    -1

    Hi Francis Martens (Exalate) ,


    I am also trying to map reporter in jira with caller id field in SNOW, 



    Outgoing Sync:

    replica.reporter       = incident.caller_id


    Incoming Sync:

    issue.reporter     = nodeHelper.getUserByUsername(replica.reporter?.username)

    Output:

    Script error for issue INC1055058. Details: Cannot cast object '{display_value=Anshuman Bakshi, link=https://amdocsuat.service-now.com/api/now/v2/table/sys_user/90b87fcfdb43a34027c24980399619d7}' with class 'scala.collection.convert.Wrappers$MapWrapper' to class 'com.exalate.api.domain.hubobject.v1_2.IHubUser' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.exalate.api.domain.hubobject.v1_2.IHubUser(scala.collection.convert.Wrappers$MapWrapper). Error line: Script676.groovy:8


    CommentAdd your comment...
  2.  
    1
    0
    -1

    > Sync status panel


    Nope there is no such thing, but you can create a custom field in service now and then copy the remote issue url there


    Check How to display the remote issue link in a custom field for more details


    1. Anshuman Bakshi

      I created a URl custom field in SNOW and followed the document and it gives me this error.


      Incoming Script on SNOW side: I tried with both names:

      incident.customFields."Related Jira Defect".value = remoteIssueUrl


      incident.customFields."u_related_jiradefect".value = remoteIssueUrl 


      Error: Script error for issue INC1055056. Details: No such property: remoteIssueUrl for class: Script429. Error line: Script429.groovy:8

    2. Francis Martens (Exalate)

      Ha - what is the version of your ServiceNow?
      We introduced it recently


      You can also use

      // this should be at the top of the processor
      import groovy.json.JsonSlurper
      
      def remoteIssueUrl = new JsonSlurper().parseText(syncRequest.replica.payload).get("issueUrl")
      
      
    3. Anshuman Bakshi

      Not sure about the SNOW version as i am a Jira Admin. 


      i tried the above one in incoming sync of SNOW and gets:  Script error for issue INC1055056. Details: Cannot set property 'value' on null object. Error line: Script456.groovy:14


      // this should be at the top of the processor
      import groovy.json.JsonSlurper

      def remoteIssueUrl = new JsonSlurper().parseText(syncRequest.replica.payload).get("issueUrl")
      incident.customFields."Related Jira Defect".value = remoteIssueUrl

    4. Francis Martens (Exalate)

      incident.customFields."Related Jira Defect" is null and cannot be dereferenced ...

    5. Anshuman Bakshi

      Hi Francis Martens (Exalate)


      As we are syncing the value of "Related Jira Defect" field and it should get value using this  remoteIssueUrl. I see issue is already existing on Jira side so can you tell me why we are getting null value.  

    6. Francis Martens (Exalate)

      incident.customFields."Related Jira Defect".value = remoteIssueUrl

      You have to use the right servicenow customfield name
      Check the post below to find out the name

    CommentAdd your comment...
  3.  
    1
    0
    -1

    Regarding the priority mapping
    When i am mapping priority values it is not syncing the values from SNOW to Jira.


    Are the values available on the replica (check remote issues tab)

    Check the 'Debugging Sync scripts on Exalate' to see whats going on and rectify

      CommentAdd your comment...
    1.  
      1
      0
      -1

      Regarding

      if (replica.status.name == "Canceled") {
          if (replica.customFields."Cancellation Notes"?.value == "Canceled by Client") {
              incident.customFields."Close Code"?.value  = "Not Solved"
          }



      Are you sure about the name of the customField?

      You can find out about the name by popping up the dictionary (right click)







      In more recent versions of the Exalate we provide shortcuts.
      Normally you should be able to use incident.estimated_delivery.value ...


      Let me know how it goes



      1. Anshuman Bakshi

        So i tried to set a basic status mapping following exalate documentation: https://docs.idalko.com/exalate/display/ED/Status+synchronization+on+Jira+Server#StatussynchronizationonJiraServer-statusSyncExternal

        Outgoing Sync(SNOW):

        replica.status = incident.state


        Incoming Sync: (Jira)

        // ["remote status name": "local status name"]
        def statusMap = ["Active": "New", "Closed": "Done", "Code Fix/Configuration Change": "Development"]
        def remoteStatusName = replica.status
        issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)


        I am  getting error and status sync is not working.

        Script error for issue INC1055058. Details: Cannot cast object 'Code Fix / Configuration Change' with class 'java.lang.String' to class 'com.exalate.api.domain.hubobject.v1_2.IHubStatus'. Error line: Script632.groovy:7


      2. Francis Martens (Exalate)

        https://docs.idalko.com/exalate/display/ED/Status+synchronization+on+Jira+Server#StatussynchronizationonJiraServer-statusSyncExternal
        Is about Jira Server sync


        Script error for issue INC1055058. Details: Cannot cast object 'Code Fix / Configuration Change' with class 'java.lang.String' to class 'com.exalate.api.domain.hubobject.v1_2.IHubStatus'. Error line: Script632.groovy:7


        Is happening on the outgoing sync (on the servicenow side) ?

        If this is the case, this is because replica.status is a status object while incident.state a string.
        You can transfer the state using for instance

        replica.customKeys.state = incident.state

        ...

      3. Anshuman Bakshi

        Thanks Francis, This is working fine now !

      CommentAdd your comment...