Json Path evaluator issues

{
    "accountRequests": [
        {
            
            "provisioningTarget": "Active Directory",
            "ticketId": "72619262",
            "attributeRequests": [
                {
                    "operation": "Add",
                    "attributeName": "memberOf",
                    "attributeValue": "CN=sales,DC=helpco,DC=com"
                },
                {
                    "operation": "Add",
                    "attributeName": "mail",
                    "attributeValue": ""
                },
                {
                    "operation": "Add",
                    "attributeName": "sAMAccountName",
                    "attributeValue": "test1234"
                }
            ]
        }
    ]
}

For the above input when I use the below Json Path query

$.accountRequests[?(@.provisioningTarget==‘Active Directory’)].attributeRequests[?(@.attributeName==‘sAMAccountName’)].attributeValue


[
  [
    "test1234"
  ]
]

Now the issue is that it should have returned a string response. Also, the result is correct if I switch the implementation from workflow to event trigger, but I need to use this as a string in the workflow. Any suggestions?

Also, the below gives exact string value back but this is not checking the attributeName dynamically.

$.accountRequests[?(@.provisioningTarget==‘Active Directory’)].attributeRequests[2].attributeValue

Yep a common issue related to array handling…

I am assuming that you are only looking for the samaccountName request’s value.

So for that maybe you can use this filter instead?

$..attributeRequests[?(@.attributeName==‘sAMAccountName’)].attributeValue

This would not filter based on the provisioningTarget, but you will be able to get the result as:

[
  "test1234"
]

And if you still want to make sure that you have the provisioingTarget check maybe you can make then on compare string’s such that if the provisioningTarget == AD then you go with the other steps.

Thanks….

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