cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Bug: Replace action on value of SharePoint lookup field gives inconsistent results

I have a Flow that performs some text substitution on values returned from a SharePoint list, assigns these to a string variable which forms the body of an email.

There is a For Each loop running the same steps with the same inputs which include some text substitutions (replacing a placeholder value in a variable with values from SharePoint list). The loop runs twice. One of the SharePoint values to be substituted is a lookup type.

On the first pass of the loop I get this (desired result):

Desk Number MS.

 

On the second pass I get this (incorrect result):

Desk Number {"@odata.type":"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference","Id":3,"Value":"MS."}

 

The offending piece of code appears to be a Compose statement (there are actually many nested 'replace' functions, but this is the relevant one):

replace(variables('strBody'),'[DeskNumber]',coalesce(body('Get_item_Person_Responsible')?['BuildingFloor_x003a_DeskPrefix']?['Value'], 'No Value Supplied'))

 

So on the second loop, despite specifying that just the 'Value' should be returned the odata specification is coming through instead.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User III
Dual Super User III

Hi!

I guess 'Get_item_Person_Responsible' is executed inside the for each loop, right?

Since there are several nested 'replace' functions, did you try to add a dummy Compose action block inside the foreach to apply this specific replace alone, and inspect its results?

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

2 REPLIES 2
Dual Super User III
Dual Super User III

Hi!

I guess 'Get_item_Person_Responsible' is executed inside the for each loop, right?

Since there are several nested 'replace' functions, did you try to add a dummy Compose action block inside the foreach to apply this specific replace alone, and inspect its results?

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

@efialttes 

Oh bother! After hours of messing around I discovered the template text with the placeholders had been overridden in the SharePoint list (multiline text field which truncates when viewed either in the list or the details pane, so I didn't notice it had been changed).

Thanks for taking a look.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (7,862)