cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hxrrisxn
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
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

Hxrrisxn
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

Hxrrisxn
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

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,704)