cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Replace expression not working

Hi,

I am trying to create a document from a HTML file. I am doing this by suing the replace expression. The Flow pulls data from a SharePoint List and uses the Replace expression to populate fields. My first expression that pulls down the HTML file works however the second does not despite being practically the same expression. Please see below:

 

Working expression - replace(outputs('Get_file_content_-_HTML')?['body'],'{title}',outputs('Get_item_-_TI_DB')?['body/Title'])

 

Failing expression - replace(outputs('Get_file_content_-_HTML')?['body'],'{Risk Rating}',outputs('Get_item_-_TI_DB')?['body/Risk Rating'])

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Replace expression not working

Hi @Hxrrisxn 

If you are confident that the value in Risk Rating is a string value you can force the expression to treat it as a string by changing it to the following.

replace(outputs('Get_file_content_-_HTML')?['body'],'{Risk Rating}',string(outputs('Get_item_-_TI_DB')?['body/Risk Rating']))

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Replace expression not working

Hi @Hxrrisxn 

Are you receiving any error messages when this Flow runs and reaches your failing expression? If so, please share the error as this may help with diagnosing the issue.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted
Frequent Visitor

Re: Replace expression not working

Hi Lee,

 

Please see below.

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '14469': 'The template language function 'replace' expects its third parameter 'new string' to be a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#replace for usage details.'.

 

 

Highlighted
Super User
Super User

Re: Replace expression not working

Hi @Hxrrisxn 

If you are confident that the value in Risk Rating is a string value you can force the expression to treat it as a string by changing it to the following.

replace(outputs('Get_file_content_-_HTML')?['body'],'{Risk Rating}',string(outputs('Get_item_-_TI_DB')?['body/Risk Rating']))

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

Highlighted
Frequent Visitor

Re: Replace expression not working

Hi Lee,

 

This allows the Flow to work. However i am trying to get the section replace to pull data from my first compose function. 

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,421)