I am trying to replace specific sections of a url by using the replace function. My intent is to replace components of the url utilizing retrieved values from a SharePoint List in a for each loop. The dynamic content I want to utilize is not available from the list when composing the replace expression for some reason so I have used a compose action to capture the information I need to later insert in the replace expression but I am unsure of how to structure the expression (I keep getting an invalid expression)
URL to modify: https://rentreadyorders.typeform.com/to/e7aKoF?market=xxxxx&name=xxxxx&id=xxxxx (I use a compose to capture this)
Replace with text: replace(outputs('RAW_URL'),'market=xxxxx','market=tri')
Replace with dyanmic content is what I dont understand: replace(outputs('RAW_URL'),'market=xxxxx','outputs('ID)') doesn't work for example.
Picture of flow attached. Ideally I would like to just directly insert the dynamic content - not sure why it isn't available when using the replace function but it is otherwise available. Secondarily if that does not work - what is the correct syntax for using the output from the previous step to insert it into the replace expression?
The easiest way to do this is by typeing the expression e..g replace()
Then move you cursor in between the brackets. Then click on dynamic content and add what you want.
Thanks @Pieter_Veenstra I understand how to insert dynamic content into the expression, in the example provided I am already using dynamic content in the initial string that the replace expression is utlizing, however I am unable to utilize dynamic content as the replacement in the structure of replace(string,'string to replace','string replacing')
The other issue I have is that when I try to insert dynamic content into an expression the dynamic content "dissapears" See below:
Thanks @Pieter_Veenstra that works but I have never been forced to use variables before, I could always do it by directly utilizing an expression in a compose action vs initiliazing and setting a variable. Does anyone know if this behavior has recently changed? I also am very perplexed as to why dynamic content is not available to me directly when writing certain expressions.
The issue is conformed on my side, we could not reference Dynamic contents from "Get items" action of SharePoint connector within replace expression currently.
If you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:
In addition, if you want to reference the Dynamic contents from "Get items" action, you could consider take a try to write WDL expression to get the specific Dynamic content from the "Get items" action. I assume that you want to replace the 'market=xxxxx' text within your RAW URL (https://rentreadyorders.typeform.com/to/e7aKoF?market=xxxxx&name=xxxxx&id=xxxxx) with a specific Dynamic content from "Get items" action, please take a try with the following formula within Compose action as below:
Note: The Product Area (shows up as Product_x0020_Area within replace expression) is a column in my SharePoint list, on your side, you should type the following formula within "Compose" action:
If there is a space within your column name, please replace the space with '_x0020_' within the replace expression.
More details about WDL expression within Microsoft Flow, please check the following article:
Hi, @WiggityZwiggity , the work around I use to win (!!!!) against this highly irritating nonsense is to put what I need openly somewhere else in a compose action, then cut it out from there, and paste it into the expression.
This way I win, and the computer doesn't beat me again, haha!
Of course, you'll need to remov... ah, here's what I'm trying to say. Let's say I've made a variable, "test", that because power automate is having it's regular hissy fit, won't let in the expression. I perform the following:
Now I can continue with my flow!
Appreciate that this is maybe a year or two later, but hope that this helps others, if not yourself.
your technique worked for me, but unfortunately still hasn't solved the challenge I'm trying to crack:
In the Power Automate Flow above, I'm trying to read rows in from an Excel spreadsheet, which I then am trying to replace the line break characters \n with a space (removing the line breaks). When I analyze my flow, I can see that the line breaks are being read in:
but unfortunately, the Compose (in the first screenshot's tooltip) I've created an expression to replace all '\n' with ' ', doesn't seem to "see" the line breaks:
Good news! After several hours of crawling forums, I managed to piece together a solution to my problem. I wanted to share it here in case others are having the same issue:
first I managed to find a (relatively simple) solution to replacing the /n line breaks by themselves in @DennisKuhn1's solution to https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/m-p/448574#M53...:
first I initialized a new variable
which just has a single press of the Enter key in the Value field. Then later in the Apply to each section of my workflow, I updated the expression in the Compose action to:
Glad that you got it sorted, @PowerDylan , sorry I came back late to this.
If I have a text string that has multiple lines that I need to parse, then my work around will almost always be (again, perhaps over-complicating) to set each line as its own entity (object?) in an array. Then they can be handled separately, as required.
I'll do that using the split expression on a newline variable (like yours), then process each array item in an Apply to each action. This way (as said) I can apply any text working that needs to be done to each line individually, then, if I do need them back as a single string with line breaks I can always join them back up.
I tend to prefer to play all my logic for things like this out in the flow, because whilst it would still work to squidge it all into a single expression or two ... that will possibly make the next person to handle my flow not really understand what's going on. And I always try to sell Power Automate as the easiest thing in the world, so I'm big on commenting, renaming, and playing out most (not all) of my logic.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.