0

I'm trying to work with the setProperty function in order to edit a JSON body during the execution of a flow, here is the expression:

setProperty(X, 'Y','bla bla 123456789' )

while

  • X is the json
  • Y the property i want to modify
  • 'bla bla 123456789' is the value

My question is: how can I replace '123456789' by a variable('ID') inside it, if I do the following thing

setProperty(X, 'Y','bla bla variable('ID')' )

It will take exactly what is written "variable('ID') and not the value of this variable !

any help ?

1

You have your variables('ID') within a string declaration so the variables object is not being accessed. You must concatenate the two separate strings ('bla bla' and variables('ID')); to do so, use the concat() function.

Your expression would look like this:

setProperty(X, 'Y', concat('bla bla ', variables('ID')))

If I am understanding the case you presented in the comments correctly, I believe you can still use the concat() function to accomplish this. You would need to concatenate the whole 'path' value with your variable ID.

The path value:

'/datasets/@{encodeURIComponent(encodeURIComponent(''.../sites/Support''))}/tables/@{encodeURIComponent(encodeURIComponent(''def533d7-8ede-4f29-b882-57d48a90c2d8''))}/onupdateditems'

would then become:

concat('/datasets/@{encodeURIComponent(encodeURIComponent(''.../sites/Support''))}/tables/@{encodeURIComponent(encodeURIComponent(''', variables('ID'), '''))}/onupdateditems')

Note that I am retaining the extra quotation marks to preserve the syntax of the original value.

The whole expression then becomes:

setProperty(body('Get_Flow')['properties']['definition'],'triggers', setProperty(body('Get_Flow')['properties']['definition']['triggers'], 'When_an_item_is_created_or_modified',setProperty(body('Get_Flow')['properties']['definition']['triggers']['When_an_item_is_created_or_modified'], 'inputs',setProperty(body('Get_Flow')['properties']['definition']['triggers']['When_an_item_is_created_or_modified']['inputs'], 'path',concat('/datasets/@{encodeURIComponent(encodeURIComponent(''.../sites/Support''))}/tables/@{encodeURIComponent(encodeURIComponent(''', variables('ID'), '''))}/onupdateditems')))))
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.