Sync multiple tickets type

Originally asked by Leandre Mundere on 14 September 2022 (original question)


Hi,

I want to sync incident and also request, but this is not working as it is creating always incident, I tried to do this in the outgoing sync:

if(entity.tableName == "incident") {

    replica.key            = entity.key
    replica.summary        = entity.short_description
    replica.description    = entity.description
    replica.attachments    = entity.attachments
    replica.comments       = entity.comments
    replica.state          = entity.state
    


if(entity.tableName =="sc_req_item"){
    replica.key = entity.key
    replica.comments = entity.comments

}

and then my incoming sync to be able to switch, i have this:

if(firstSync){
if(replica.tableName == "incident"){
    entity.tableName = "incident"
}
if(replica.tableName == "sc_req_item"){
entity.tableName = "sc_req_item"
}
}

But this is not working, anybody knows what I have wrong?

Thanks


Comments:

Ariel Aguilar commented on 16 September 2022

Hi there,

Is this a local connection? Or what other instance besides ServiceNow is synchronized? For example, if the Jira remote type is Bug, you could try to do something in ServiceNow incoming script like:

if(firstSync){
 //Decide on the first sync, which entity you want to create based on the remote issue type
 if(replica.typeName == "Bug"){
    entity.tableName = "sc_req_item"
 }else{
    entity.tableName = "incident" 
}
}
if(entity.tableName == "sc_req_item") {
    entity.short_description = replica.summary
    entity.description = replica.description
    entity.comments += replica.addedComments
    entity.attachments += replica.addedAttachments
}
if(entity.tableName == "incident") {
    entity.short_description = replica.summary
    entity.description = replica.description
    entity.comments += replica.addedComments
    entity.attachments += replica.addedAttachments
}

Kind regards,

Ariel