Use JSONPath filter in variable definition

Hello everyone,

I am trying to use a JSONPath filter expression to get the attribute value from the provisioning plan to store it on a variable for later use. The expression I’m using is the following, which appears to be correct when I try it on https://www.javainuse.com/jsonpath.

$.target.accountRequests[?(@.source.name == 'Directorio Activo')].attributeRequests[?(@.attributeName == 'mail')].attributeValue

However, when I test the workflow the expression is not replaced for the actual value of the input.

I have also tried escaping the double quotes in the expression like this:

$.target.accountRequests[?(@.source.name == \"Directorio Activo\")].attributeRequests[?(@.attributeName == \"mail\")].attributeValue

But the result is the same. As a last resort, I tried putting the expression in the variables for the “Send Email” action directly, but no luck.

Does anyone know what I may be doing wrong?

You can find the workflow json attached and the test input I’m using if you want to replicate the issue.
AD-Create-Test_Input.json (2,7 KB)
AD-Create-Workflow.json (41,0 KB)

Kind regards,
Pablo

Hi everyone,

An update, after more tests I found I had a mistake, the query should be:

$.trigger.accountRequests[?(@.source.name == 'Directorio Activo')].attributeRequests[?(@.attributeName == 'mail')].attributeValue

And now if I check the step input in the test I can see it replaced correctly, but the output is still empty.


For some reason the input is replacing the value as an array, rather than a string, but I tried adding [0] at the end of the JSONPath but then it returns nothing.

Kind regards,
Pablo

Hi @pizquierdo,

To get the email ID, can you try with an HTTP action node, calling the Accounts API

The request URL would look something like this

https://YOURTENANT.api.identitynow.com/v3/accounts?filters=sourceId%20eq%20%22REPLACEYOURSOURCEIDHERE%22%20and%20identityId%20eq%20%22{{$.getIdentity.id}}%22

This call would fetch you the user’s account from your AD source.

Then the email ID can be derived by calling $.hTTPRequest.body[*].attributes.mail

Hello @jesvin90 ,

That’s a great idea. I’ll try it and let you know.

Kind regards,
Pablo

Hello, it works perfectly!

Thanks!

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