Workflow - Define Variable - Input string has a list

I am working on a workflow that will compare the USER ID that we get from WD and compare it with the other connected sources. I am using the define variable action in order to just extract the USER ID’s for each of the sources.

Connected Sources:
ServiceNow - Test
ServiceNow - Training
Workday - Sandbox
Active Directory - Lab

I am able to successfully define AD and WD USER ID’s using the Json Path. When I get to Service now it has an input list object so the variable never sets the value from the list. I have tried a number of thing to dig into the list and have come up with the same results or no results at all. Anyone have any ideas how I can extract the first value in the list?

Input Object:

{
  "id": "sp:define-variable",
  "variables": [
    {
      "description": "",
      "name": "Workday SamAccountName",
      "transforms": [],
      "variableA": "dmcmil0"
    },
    {
      "description": "",
      "name": "AD SamAccountName",
      "transforms": [],
      "variableA": "dmcmil02"
    },
    {
      "description": "",
      "name": "ServiceNow SamAccountName",
      "transforms": [],
      "variableA": [
        "dmcmil02",
        "dmcmil02"
      ]
    }
  ]
}

Step Output:

{
  "aDSamAccountName": "dmcmil02",
  "serviceNowSamAccountName": "",
  "workdaySamAccountName": "dmcmil0"
}

Full Workflow Json Config:

{
    "id": "0682e84d-36d3-4d00-83ae-142aa55f66da",
    "name": "POC - User with multiple UserIDs",
    "description": "",
    "created": "2024-04-25T18:48:37.539346923Z",
    "modified": "2024-04-25T20:22:39.341495611Z",
    "modifiedBy": {
        "type": "IDENTITY",
        "id": "REMOVED",
        "name": "REMOVED"
    },
    "definition": {
        "start": "Get Identity",
        "steps": {
            "Compare Strings": {
                "choiceList": [
                    {
                        "comparator": "StringEquals",
                        "nextStep": "Compare Strings 2",
                        "variableA.$": "$.defineVariable.workdaySamAccountName",
                        "variableB.$": "$.defineVariable.aDSamAccountName"
                    }
                ],
                "defaultStep": "Compare Strings 1",
                "displayName": "Compare Strings WD to AD",
                "type": "choice"
            },
            "Compare Strings 1": {
                "choiceList": [
                    {
                        "comparator": "StringEquals",
                        "nextStep": "Send Email",
                        "variableA.$": "$.defineVariable.workdaySamAccountName",
                        "variableB.$": "$.defineVariable.serviceNowSamAccountName"
                    }
                ],
                "defaultStep": "Send Email",
                "displayName": "Compare Strings WD to SNow",
                "type": "choice"
            },
            "Compare Strings 2": {
                "choiceList": [
                    {
                        "comparator": "StringEquals",
                        "nextStep": "End Step - Success",
                        "variableA.$": "$.defineVariable.workdaySamAccountName",
                        "variableB.$": "$.defineVariable.serviceNowSamAccountName"
                    }
                ],
                "defaultStep": "Send Email",
                "displayName": "Compare Strings WD to SNow",
                "type": "choice"
            },
            "Define Variable": {
                "attributes": {
                    "id": "sp:define-variable",
                    "variables": [
                        {
                            "description": "",
                            "name": "Workday SamAccountName",
                            "transforms": [],
                            "variableA.$": "$.hTTPRequest.body[*].attributes.USERID"
                        },
                        {
                            "description": "",
                            "name": "AD SamAccountName",
                            "transforms": [],
                            "variableA.$": "$.hTTPRequest.body[*].attributes.sAMAccountName"
                        },
                        {
                            "description": "",
                            "name": "ServiceNow SamAccountName",
                            "transforms": [],
                            "variableA.$": "$.hTTPRequest.body[*].attributes.user_name"
                        }
                    ]
                },
                "displayName": "",
                "nextStep": "Compare Strings",
                "type": "Mutation"
            },
            "End Step - Success": {
                "displayName": "",
                "type": "success"
            },
            "Get Identity": {
                "actionId": "sp:get-identity",
                "attributes": {
                    "id.$": "$.trigger.recipient.id"
                },
                "displayName": "",
                "nextStep": "HTTP Request",
                "type": "action",
                "versionNumber": 2
            },
            "HTTP Request": {
                "actionId": "sp:http",
                "attributes": {
                    "authenticationType": "OAuth",
                    "jsonRequestBody.$": "",
                    "method": "get",
                    "oAuthClientId": "REMOVED",
                    "oAuthClientSecret": "REMOVED",
                    "oAuthCredentialLocation": "oAuthInHeader",
                    "oAuthTokenUrl": "REMOVED",
                    "requestContentType": "json",
                    "url": "REMOVED",
                    "urlParams": {
                        "filters": "identityId eq \"{{$.getIdentity.id}}\""
                    }
                },
                "displayName": "",
                "nextStep": "Define Variable",
                "type": "action",
                "versionNumber": 2
            },
            "Send Email": {
                "actionId": "sp:send-email",
                "attributes": {
                    "body": "<p>Workday ID:  ${WorkdayID}</p>\n<p>AD ID: ${ADID}</p>\n<p>ServiceNow ID: ${ServiceNowID}</p>",
                    "context": {
                        "ADID.$": "$.defineVariable.aDSamAccountName",
                        "ServiceNowID.$": "$.defineVariable.serviceNowSamAccountName",
                        "WorkdayID.$": "$.defineVariable.workdaySamAccountName"
                    },
                    "from": "[email protected]",
                    "recipientEmailList": [
                        "REMOVED",
                        "REMOVED"
                    ],
                    "subject": "User has missed matched account ids"
                },
                "displayName": "",
                "nextStep": "End Step - Success",
                "type": "action",
                "versionNumber": 2
            }
        }
    },
    "enabled": false,
    "executionCount": 0,
    "failureCount": 0,
    "creator": {
        "type": "IDENTITY",
        "id": "REMOVED",
        "name": "REMOVED"
    },
    "owner": {
        "type": "IDENTITY",
        "id": "REMOVED",
        "name": "REMOVED"
    },
    "trigger": {
        "type": "EVENT",
        "attributes": {
            "id": "idn:post-provisioning"
        }
    }
}

Hmm, I don’t think the define variable operation supports lists, you may have to use a loop and iterate over the ServiceNow usernames and create a separate variable for each one.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.