Recherches récentes


Pas de recherche récente

ZIS flow working with multiple variables in a transform action



Publication le 27 nov. 2023

Hey all,

I've build a flow to update the phone identities of a user if specific custom fields have been changed.

What I did so far is, that I get the previous custom field value (e.g. +49 030123), it is the value of the variable: $.input.user_event.previous and with that I call the identities endpoint and find out the identityID to make an update with the current value ($.input.user_event.current).

That works very well so far with these expression:

"expr": '.identities[] | select(.value == "+49 030123") | .id | tostring',

Now I would like to use not the hardcoded number, rather the variable itself -> $.input.user_event.previous and my code looks like this:

 

"find_phone": {
          "Type": "Action",
          "ActionName": "zis:common:transform:Jq",
          "Parameters": {
            "data.$": "$.identities",
            "expr": '.identities[] | select(.value == "{{$.input.user_event.previous}}") | .id | tostring',
          },
          "ResultPath": "$.identity",
          "Next": "Ok"
        },

 

But it doesn't work, it seems that the previous variable is blank. It works only with a hardcoded value. So it seems that it is not possible to access to the input variable because the expression is within the data parameter $.identity (which is the API output of all identities of an user).

I am totally confused because if I use just a message to log it, works. My code looks like this:

"Ok": {
"Type": "Succeed",
"Message": "Phone need to be change. ID: {{$.identity}} Value: {{$.input.user_event.previous}}"
}
 
Does the transform action need the input variable as a second parameter to access to it? How can I handle it?
 
Thanks in advance

0

3

3 commentaire

Ok it works with passing data before.

0


Hey Greg!

I tried it in this way:
"expr": ".identities[] | select(.value == {{$.input.user_event.previous}}) | .id | tostring"

 
Result:
Action Error: zis:common:transform:Jq ActionState(find_phone) Error: Encountered parsing error: error parsing jq output: unexpected token "{"

And in this way:
"expr": ".identities[] | select(.value == '{{$.input.user_event.previous}}') | .id | tostring"

Result:
ActionState(find_phone) Error: Encountered parsing error: error parsing jq output: unexpected token "'"
 
Any other idea?

0


Hi Nawed! I haven't had a lot of time to play around with ZIS, however, I'm wondering if the issue has to do with the single quotes that you use in the "expr":key. Could you switch that to double quotes and then remove the trailing comma if it's the last parameter in that object and let me know if that resolves it?

0


Vous connecter pour laisser un commentaire.

Vous ne trouvez pas ce que vous cherchez ?

Nouvelle publication