
Announcements
Hello guys,
This post will be a little bit long, I hope you would be patient with me and excuse my poor English
I have a SharePoint List (let's call it ListA), I create an associated flow that do some notification actions, all of this is working very well.
Now I won't have just one list, in the future i will have "n similar lists" which they will need the same flow, I couldn't find a way to create one flow that handle everything for these all lists, so i realised I can quite simply duplicate that flow (Save as copy) then edit the list name in the flow trigger, right ?
since the SharePoint site will be used by a simple users (which they don't have access to Power Automate and duplicate the flow), I need to do it automatically when a new list is created !
so what i have done until now:
Now the problem that i have encountered until now:
Note that the value of "path" is: "/datasets/@{encodeURIComponent(encodeURIComponent('.../sites/Support'))}/tables/@{encodeURIComponent(encodeURIComponent('3939098e-a076-48e8-b020-b0df1589b327'))}/onupdateditems"
While I should change that ID ''3939098e-a076-48e8-b020-b0df1589b327" by another one I just got and save it in a variable
So I searched for a way to edit this JSON, and I found an expression named "setProperty(<object>, '<property>', <value>)" and in order to edit that "path" property, I need to use nested setProperty (please refer to this link to understand what i'm saying)
here is what I build:
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','/datasets/@{encodeURIComponent(encodeURIComponent(''.../sites/Support''))}/tables/@{encodeURIComponent(encodeURIComponent(''def533d7-8ede-4f29-b882-57d48a90c2d8''))}/onupdateditems' ))))
as you can see at the end of this expression, I used the two quotes ('') to use the quote inside that expression (for example, inside a concatenation expression
So, the previous expression setProperty i mentionned above, it works fine and the new flow in created perfectly with the new name of the new list (let's call it ListB), but my desire is to replace the new ID dynamically and not like i've done so far, it should like this:
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','/datasets/@{encodeURIComponent(encodeURIComponent(''.../sites/Support''))}/tables/@{encodeURIComponent(encodeURIComponent(''def533d7-8ede-4f29-b882-57d48a90c2d8''))}/onupdateditems' ))))
and this will replace put the text exactly as it is "variables('ID')", while it should replace the value of this variable !
Thank you.
check out wonder laura's blog for some tips on this it is what got me to a working solution, but you are right it is not pretty.