1
0
-1

When we try to send the priority from ServiceNow in the outgoing script to DevOps, the priority value is showing as the urgency value in the replica payload.  How can we pull the correct priority value from ServiceNow to send and sync with DevOps?

    CommentAdd your comment...

    3 answers

    1.  
      2
      1
      0

      I just worked this out myself a few days ago. Here's what I did.

      On the ServiceNow side:

      // Outgoing
          replica.priority  = entity.priority
      
      // Incoming:
      
      //first set up a map between the two to translate the input from ADO into something SNOW could use:
      
      def PriorityMap = [
          "1" : "1 - Critical",
          "2" : "2 - High",
          "3" : "3 - Moderate",
          "4" : "4 - Low"
          ]
      
      // next get the input from ADO and map it to the appropriate  priority type for SNOW. // If you get something you don't expect then just call it "4 - Low"
      
          def targetPriority = PriorityMap[replica.priority.name] ?: "4 - Low" 
          entity.priority = nodeHelper.getPriority(targetPriority)


      ADO side:


      // Outgoing
      
          replica.priority   = workItem.priority
      
      // Incoming
      // same process in reverse, create a mapping for disparate data types:
      
      def PriorityMap = [
          "1 - Critical" : "1",
          "2 - High" : "2",
          "3 - Moderate" : "3",
          "4 - Low" : "4",
          ]
      
      // Use the PriorityMap to translate SNOW into ADO and then the helper to put it in the correct data type format
      
          def targetPriority = PriorityMap[replica.priority.name] ?: "4"
          workItem.priority = nodeHelper.getPriority(targetPriority) 
          



      That's what worked for me. Hope that helps!

      1. Chris Lund

        Jack Handy Thank you for that piece of code, but we are still having issues in syncing the priorities.  On the outgoing from SNow to ADO, the priority field is updating but only to P4, in the payload the priority value is still being sent as the urgency value.  We have different values for urgency and priority, example urgency = '1 - High' and priority = '1 - Critical', so mapping these values isn't working because it is sending a value we aren't expecting so it always get set as 4. 


        Conversely on the incoming to SNow only the urgency is getting set, it will update the priority field if the urgency/impact matrix determines a new priority.  I realize that we could and probably will just copy that matrix over to ADO and determine priority the same way, but now I'm just curious if it's even possible to send the actual priority value in the payload

      2. Jack Handy

        I was going at this the wrong way. I was able to reproduce this. I thnk it's a bug.

        On the second part:

        You can send priority but I don't think SNow will accept the input to that field as it's "calculated" from the other values.


      3. Jack Handy

        I reported this to them as a bug. In the meantime if you wanted to have some fun you could put together a matrix of possible values:

        impact & urgency = priority
        1 & 1 = 1 Critical
        1 & 2 = 2 High
        1 & 3 = 3 Moderate
        2 & 1 = 2 High
        2 & 2 = 3 Moderate
        2 & 3 = 4 Low
        3 & 1 = 3 Moderate
        3 & 2 = 4 Low
        3 & 3 = 4 Low

        Then use a switch or if statement to build the correct value to send and use something like


        if(entity.impact.contains("Low") && entity.urgency.contains("High"){
            replica.priorityVal = "3 - Moderate"
            }

        I haven't tested this but I think it should work until this gets explained/fixed.

      4. Francis Martens (Exalate)

        I can confirm this was a bug.
        We mixed up urgency and priority. 

        To keep backward compatibility we had to introduce


        • priorityValue (to reflect the priority field)
        • urgencyValue (to reflect the urgency field)



        Check for this How to sync urgency and priority between ServiceNow and Jira
        Which is pretty similar to the way it can be done between ServiceNow and Azure DevOps

      5. Chris Lund

        Francis Martens (Exalate) Thanks for that link, I was able to fix the priority issue and now it is syncing between the 2 systems using priorityValue.  If you had not provided that I was planning on implementing something along the lines of what Jack Handy commented below.  Thanks again for all your help!

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

      I notice that the other priority syncs that were working are not working now. Still trying to figure it out.
      Syncing Incidents to Bugs still works with the fix above.
      Priority for Enhancements in ServiceNow sync to Enhancements in Azure just fine.


      The exact same configuration for other record types doesn’t work. I can sync from SNow to Azure but not the other way around. I used to be able to do this until  the day before yesterday.

      The code below shows the relevant code for two examples. One works and the other does not.

      Azure Out:
      
      
      replica.priority = workItem.priority
      replica.priorityName = workItem.priority.name
      ...
      
      Azure Incoming:
      def PriorityMap = [
      "1 - Critical" : "1",
      "2 - High" : "2",
      "3 - Moderate" : "3",
      "4 - Low" : "4"
      ]
      def my_priority = PriorityMap[replica.priority.name] ?: "4 - Low"
      workItem.priority = nodeHelper.getPriority(my_priority) 
      ---------------------
      
      ServiceNow Out:
      if(entity.tableName == "rm_enhancement") {
         replica.priority = entity.priority
         ...
      }
      if(entity.tableName == "dmn_demand") {
         replica.priority = entity.priority
         ...
      }
      
      ServiceNow Incoming:
      def PriorityMap = [
      "1" : "1 - Critical",
      "2" : "2 - High",
      "3" : "3 - Moderate",
      "4" : "4 - Low",
      "5" : "5 - Planning"
      ]
      if(entity.tableName == "rm_enhancement") {
         ...
         def targetPriority = PriorityMap[replica.priorityName] ?: "4 - Low"
         entity.priority = nodeHelper.getPriority(targetPriority)
      }
      
      if(entity.tableName == "dmn_demand") {
         ...
         def targetPriority = PriorityMap[replica.priorityName] ?: "4 - Low"
         entity.priority = nodeHelper.getPriority(targetPriority)
      }
      1. Francis Martens (Exalate)

        Hi Jack Handy 

        What is not working?
        Can you check the targetPriority and the found priority with getPriority for the entities rm_enhancement, dmn_demand - and check if the provided provided priorities match the values allowed for this field

        Please use

        debug.error("Targetpriority = ${targetPriority}")
      CommentAdd your comment...
    3.  
      1
      0
      -1

      Got the priority thing worked out. It took a while!


      On the ServiceNow side:


      Outgoing

      concatenate the urgency and impact values together to make a unique identifier for each case. 

      if(entity.tableName == "incident") {
          replica.priorityName       = entity.impact + entity.urgency
      
          ...
      
      }


      On the Azure side:


      Incoming


      Create a map of possible combinations with the value they need to represent on the ADO side.

      if(issueUrl.contains("incident")){
          //workitem.priority = nodeHelper.getPriority(replica.priority.name)
          workItem.summary = replica.summary
      def PriorityConstructor = [
        "1 - High1 - High" : "1",
        "1 - High2 - Medium" : "2",
        "1 - High3 - Low" : "3",
        "2 - Medium1 - High" : "2",
        "2 - Medium2 - Medium" : "3",
        "2 - Medium3 - Low" : "4",
        "3 - Low1 - High" : "3",
        "3 - Low2 - Medium" : "3",
        "3 - Low3 - Low" : "4"
        ]
          my_priority = PriorityConstructor[replica.priorityName]
          workItem.priority = nodeHelper.getPriority(my_priority)
      }

      I'm proud of this one. (smile)

      1. Francis Martens (Exalate)

        Great approach to combine impact and urgency!

      2. Jack Handy

        Thanks. I'm still new to a lot of this so even though this isn't all thst "fancy" it's pretty fancy for me! (smile)

      CommentAdd your comment...