2
1
0

We are trying to sync an issue type of Change in Jira Software with a Change request in ServiceNow. When looking at the field in ServiceNow I see that the column name is type and the choices (values) are standard, normal and emergency. This is a standard (not custom) field in ServiceNow but it seems that I can't sync to or from this field.  Both fields are Select Lists.


Here is the setup:

Jira Outgoing sync

replica.customFields."Change Type" = issue.customFields."Change Type"


ServiceNow Incoming sync

def changeTypeMap = [    
    "Normal" : "normal",         
    "Emergency" : "emergency",
    "Standard" : "standard"
    ] 
def remoteChangeType = replica.customFields."Change Type"?.value?.value

entity.type = (changeTypeMap[remoteChangeType]?: remoteChangeType)


To check the data:

debug.info("replica.customFields.'Change Type'?.value?.value = ${replica.customFields.'Change Type'?.value?.value}")

Results:

replica.customFields.'Change Type'?.value?.value = Normal


debug.info("remoteChangeType = ${remoteChangeType}")

Results:

remoteChangeType = Normal


debug.info("ChangeTypeMap is ${changeTypeMap[remoteChangeType]}")

Results:

ChangeTypeMap is normal


entity.type = (changeTypeMap[remoteChangeType]?: remoteChangeType)

Results:

Cannot cast object 'normal' with class 'java.lang.String' to class 'com.exalate.api.domain.hubobject.v1_2.IHubIssueType'


Jira Payload


ServiceNow Payload

because it has not been created yet.


Edited

entity.type = (changeTypeMap[remoteChangeType]?: remoteChangeType)

To

entity.type?.value = (changeTypeMap[remoteChangeType]?: remoteChangeType)


debug.info("entity.type?.value is ${entity.type?.value}")

Result:

entity.type?.value is null


Edited

entity.type?.value = (changeTypeMap[remoteChangeType]?: remoteChangeType)

To

entity.type?.name = (changeTypeMap[remoteChangeType]?: remoteChangeType)


debug.info("entity.type?.name is ${entity.type?.name}")

Result

entity.type?.name is null


Edited

entity.type?.name = (changeTypeMap[remoteChangeType]?: remoteChangeType)

To

entity.type?.value?.name = changeTypeMap[remoteChangeType]?: remoteChangeType


debug.info("entity.type?.value?.name  is ${entity.type?.value?.name }")

Result

entity.type?.value?.name is null


These values are null but the Change IS created in ServiceNow as a Normal change since it is the default type.

However when syncing back to Jira, we get an error:

Could not update issue `183,920`: Field customfield_10112: Specify a valid 'id' or 'name' for Change Type. Check the documentation for more details.

The issue and the field exist. 


ServiceNow Outgoing sync

replica.type = entity.type


Jira Incoming sync

def typeMap = [

   // ["remote options" : "local option"]

    "normal" : "Normal",          

    "emergency" : "Emergency",

    "standard" : "Standard"


    ]

def remoteChangetype = replica.type

issue.customFields."Change Type"?.value?.value = typeMap[remoteChangetype]?: remoteChangetype


debug.info(("remoteChangetype is ${remoteChangetype}"))

Result

remoteChangetype is null


ServiceNow payload – does not include any “type” field at all. 


Edited

def remoteChangetype = replica.type

To

def remoteChangetype = replica.type?.value.?name


debug.info(("remoteChangetype is ${remoteChangetype}"))

Result

remoteChangetype is null


So it seems that ServiceNow is not sending entity.type data or it is not the right field. 

To test that, I created an Emergency Change in ServiceNow to sync over to Jira. 


ServiceNow Outgoing sync

replica.type = entity.type


Jira Incoming sync

def typeMap = [

   // ["remote options" : "local option"]

    "normal" : "Normal",          

    "emergency" : "Emergency",

    "standard" : "Standard"


    ]

def remoteChangetype = replica.type?.name

issue.customFields."Change Type"?.value?.value = typeMap[remoteChangetype]?: remoteChangetype



ServiceNow payload

Where is issueType coming from?


Jira Payload


This created a Normal Change in Jira and that Normal type synced back to ServiceNow somehow. 

Updated the ServiceNow Outgoing sync to 

replica.type = entity.issueType


Same result.


What am I missing here? I have tried more than what I have entered here but am running out of ideas. 

    CommentAdd your comment...

    1 answer

    1.  
      4
      3
      2

      Hi Karen Jennings 

      We have been looking into this question

      Jira to Servicenow


      Take into account that the  the class of entity.type  is BasicHubIssueType

      As there is no native exalate support to construct this object through a helper method, you need to construct the object you assign by

      • import the class
      • Instantiate the object 
      • Assign it to entity.type


      import com.exalate.basic.domain.hubobject.v1.BasicHubIssueType
      ...
      
      def normalType = new BasicHubIssueType()
      normalType.name = "emergency"
      entity.type = normalType



      This works fine on the sync from Jira to ServiceNow
      (you will have to wire in the mapping)



      ServiceNow to Jira


      The type will only be included in the payload if you add it to the outgoing sync script 


      For instance - you can do 

      ServiceNow - Outgoing sync
      // replica.change_type will either have Standard, Normal or Emergency
      
      replica.change_type = entity.type.name



      And this can then be used on the Jira side


      Jira Incoming
      def changeTypeMapping = [
      		"normal" : "Normal",
       		"standard" : "Standard",
        		"emergency" : "Emergency",
       
          ]
      
      
      // extract the change type out of the replica, map it and if not found default to 'Normal'
      def remoteChangeType = changeTypeMapping[replica.change_type] ? "Normal"
      
      
      // assign it to the value attribute of the change type custom field
      issue.customFields."Change Type".value = remoteChangeType
      
      



      1. Karen Jennings

        Thanks Francis Martens (Exalate)  I will look into this and let you know how it goes. 

        Where do I need to put the import? 

      2. Francis Martens (Exalate)

        At the beginning of the script (line 1 if there is no other import)

      CommentAdd your comment...