The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Questions

 
1
0
-1

Hi, 


We are trying to set value for close code field in SNOW whose value depends on value of field Cancelation reason in JIRA. for example: if issues status is Canceled in Jira and value of  cancellation reason in Jira is "Canceled by Client"  then value of fields close code and close note in snow should be updated. 


I am trying below queries:


Outgoing Sync in Jira : 


replica.customFields."Cancellation Reason" = issue.customFields."Cancellation Reason"




Incoming Sync in SNOW:


//Status Mapping 
def statusMap = ["Done": "Resolved","Canceled": "Resolved","Impediment": "Awaiting User Info"] 
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
if (replica.status.name == "Done") {
incident.close_notes = "Resolution notes in JIRA"
incident.close_code = "Solved (Permanently)"
}

if (replica.status.name == "Canceled") {
if (replica.customFields."Cancellation Reason".value == "Canceled by client"){
incident.close_notes = "Canceled by customer"
incident.close_code = "Not Solved (canceled by customer)"
}
}


this is not giving error, but close code and close notes value is not getting updated when Jira Status = Canceled. 


Please let me know how to fix this ?


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Can you check if the if branch is being reached by adding something like

      //Status Mapping 
      def statusMap = ["Done": "Resolved","Canceled": "Resolved","Impediment": "Awaiting User Info"] 
      def remoteStatusName = replica.status.name
      issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
      if (replica.status.name == "Done") {
      incident.close_notes = "Resolution notes in JIRA"
      incident.close_code = "Solved (Permanently)"
      }
      
      // Show some variables in the error
      throw new Exception("Replica.status.name == ${replica.status.name}, replica.customFields."Cancellation Reason".value == ${replica.customFields."Cancellation Reason".value}")
      
      if (replica.status.name == "Canceled") {
      if (replica.customFields."Cancellation Reason".value == "Canceled by client"){
      incident.close_notes = "Canceled by customer"
      incident.close_code = "Not Solved (canceled by customer)"
      }


      You need to have a pending incoming sync to trigger the exception.

      If this shows the wrong value - dive into that section, if it shows the right value - add a throw in the if branch


      //Status Mapping 
      def statusMap = ["Done": "Resolved","Canceled": "Resolved","Impediment": "Awaiting User Info"] 
      def remoteStatusName = replica.status.name
      issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
      if (replica.status.name == "Done") {
      incident.close_notes = "Resolution notes in JIRA"
      incident.close_code = "Solved (Permanently)"
      }
      
      
      
      
      if (replica.status.name == "Canceled") {
      if (replica.customFields."Cancellation Reason".value == "Canceled by client"){
      // Show that the branch is reached
      throw new Exception("Now in the right branch")
      
      incident.close_notes = "Canceled by customer"
      incident.close_code = "Not Solved (canceled by customer)"
      }

      If the branch is reached - check that there are no permission restrictions on the field (that is possible in the servicenow).

      If there are permission restrictions - clear them for the proxy user
      Try again


        CommentAdd your comment...