1
0
-1

I am setting up a sync between ADO and serviceNow. I want to sync the following:

bug == incident

enhancement == enhancement

demand == demand 


The demand and enhancement items in ADO are custom work items but I don't think that maters. How can I determine in my incoming sync for SNow what type of ADO record it is so it creates the correct record on the SNow side? I've Googled a bit and not found this but I assume it's quite common.

TIA

  1. Ariel Aguilar

    Hi Jack,


    This should help!

    ADO Outgoing script:

    replica.type = issue.type

    ADO Incoming script:

    //map issue types between source and destination instances.
    def issueTypeMapping = [
    // "remote issue type" : "local issue type"
      "Incident" : "Bug",
      "Enhancement" : "Enhancement"
      "Demand" : "Demand"
    ]
    issue.typeName = issueTypeMapping[replica.type?.name]

    Servicenow Outgoing Script:

    replica.type = issue.type

    Servicenow Incoming script:

    //map issue types between source and destination instances.
    def issueTypeMapping = [
    // "remote issue type" : "local issue type"
    "Bug" : "Incident",
    "Enhancement" : "Enhancement"
    "Demand" : "Demand"
    ]
    issue.typeName = issueTypeMapping[replica.type?.name]

    Let me know if that works for you. Just make sure to use the correct issue type names when adding them. For more reference, you can take a look at: https://docs.idalko.com/exalate/x/gIYrAQ

    Kind regards,

    Ariel

  2. Jack Handy

    Looks like I'm getting closer. When I try to sync from SNOW my outgoing replica looks like this:

    {
      "version": {
        "major": 1,
        "minor": 14,
        "patch": 0
      },
      "hubIssue": {
        "state": "New",
        "issueTypeName": "incident",
        "components": [],
        "attachments": [],
        "voters": [],
        "customFields": {},
        "description": "[]",
        "watchers": [],
        "fixVersions": [],
        "key": "INC00096434",
        "summary": "Another new incident  MFP",
        "comments": [],
        "internalMap": {
          "state": "New"
        },
        "labels": [],
        "customKeys": {},
        "workLogs": [],
        "affectedVersions": [],
        "entityProperties": {}
      },
      "issueUrl": "https://Company.service-now.com/nav_to.do?uri=incident.do?sys_id=e96b9195db7efc909d1b18df4b961900"
    }
    
     
    So I see the issueTypeName is coming across but it's not working on the other side. Since this is a new item it's failing on the firstSync creation which looks like this on the ADO side:
    
    def issueTypeMapping = ["incident" : "Bug","enhancement" : "Enhancement","dmn_demand" : "Demand" ] 
    issue.typeName = issueTypeMapping[replica.issueTypeName]
    
    if(firstSync ){
        //Decide on the first sync, which entity you want to create based on the remote issue type
        //workItem.typeName = issue.typeName ?: "Bug"
        workItem.type = issue.typeName
    }

    I've tried a couple different methods to give it a default value that works but  the only thing that works is 
     workItem.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Bug"
    which just makes every new item a bug regardless of what I send across.


    I'm sure I'm missing something simple here. 

  3. Jack Handy

    To clarify, this works with any valid workitem type but tattoos all new items as that thing regardless of what they are on the SNow side; which suggests it's not getting valid data that it can extract the workItem type from. 
     workItem.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: <AnyValidWorkitemType>

  4. Ariel Aguilar

    We can suggest to do a slight change on the Azure Incoming script to be:

    def issueTypeMapping = ["incident" : "Bug","enhancement" : "Enhancement","dmn_demand" : "Demand" ] 
    workItem.typeName = issueTypeMapping[replica.typeName]

    Kind regards,

    Ariel

  5. Jack Handy

    I was able to come up with a way to solve this. I imagine it's not very elegant but it works for now. (smile) Later I will come up with a more economical way to do this but in the meantime here its is:


    Outgoing sync from the SNow side. Very basic at this point. Just making it work.

    if(entity.tableName == "rm_epic") {
      replica.short_description       = entity.short_description
      replica.description             = entity.description
      //replica.correlation_id        = entity.correlation_id
      //replica.correlation_display   = entity.correlation_display
      //replica.assigned_to           = entity.assigned_to
      //internalMap.short_description
    }



    Incoming sync on the Azure side. 

    if(firstSync){
        if(issueUrl.contains("rm_epic") ){
            workItem.typeName =  "Epic";
        }
        if(issueUrl.contains("ENHC") ){
            workItem.typeName = "Enhancement";
            }
        if(issueUrl.contains("incident") ){
            workItem.typeName = "Bug";
            }
        if(issueUrl.contains("DMND") ){
            workItem.typeName = "Demand";
            }
        if(issueUrl.contains("rm_story") ){
            workItem.typeName = "User Story";
           }
    } 



    I did attempt you updated method but I still couldn't get it to work. Not sure what I was doing wrong..

CommentAdd your comment...