web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / is it possible to repl...
Power Automate
Answered

is it possible to replace multiple strings in one replace function?

(0) ShareShare
ReportReport
Posted on by

Im running into the following problem:

 

Got a flow that creates folders in SharePoint from Accounts in CRM dynamics.

But in CRM it is possible to use special characters in the accountname.

 

When the flow gets triggered and a special character is used.

It fails because a folder name can`t contain one of these characters.

 

Example of invalid characters:

# % * : < > ? /  |

 

Im trying to replace these characters with @replace. But i dont know if its possible to replace all the characters in one function?

 

What i got now is:

 

replace(body('Account')['name'], '#, %, *, :, <, >, ?, /, |', '')

 

Please let me know if its possible

Categories:
I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Oke so i have been trying a lot of things and came up with a solution.

     

    I created an array in the Flow with all the characters that are invalid.

    Then created a foreach loop.

    In this loop i let the replace function loop through all items in the array and change the string with the invalid character.

     

    SO its fixed.

     

    If anyone is interessted so below for the short version:

     

    array.PNG

     

     

    replace accountname.PNG

     

    replace it with this expression:

    replace(body('Account_ophalen_in_foreach')['name'], item(), '')

     

    body('Account_ophalen_in_foreach')['name'] = the action to get account from dynamics and [name] is the name.

  • GrzegorzM Profile Picture
    18 on at

    Hi,

     

    This is very interesting, but I cannot make it work. I want to clear a text from all special characters.

     

    When I run a loop, every time it starts from the initial text...

     

    Could you post a full screen of your flow, including your loop?

     

    My flow looks like this, but it does not work like I want it. It replaces each character individually - but I do not get one "clear" output text...

     

    2017-11-02 09_46_14-Edit your flow _ Microsoft Flow - Internet Explorer.png

     

    Thanks!

     

  • Community Power Platform Member Profile Picture
    on at

    Hi,

     

    I had this problem also.

    This is because u have to include the result in your loop.

     

    In my case i`m eliminating the special characters from the accountname and the subject name of a sales opportunity(SO) in CRM.

    This means i have to start with getting the variable of the accountname and subject of SO.

    Then start the replacement. (i edit an extra check if variable is different from the original variable and the replacement variable, if yes then it will change the name according to the new name without a special character). 

    If the accountname has multiple special characters in the name, it will delete the special characters one by one)

     

    When the loop starts again after a special character has already been removed, it will start looking for a new special characters with the change name of subject. i hope this is clear 🙂

     

    A few printscreens from my loop:

     

    (somehow i cant insert pictures) Ill post them asap.Knipsel.PNG

  • SimonH Profile Picture
    8 on at

    could post a screenshot of your expanded condition?

    But if Iunderstand you correctly, in your condition you are writing back to dynamics, so when the loop starts again it works with the updated variable?

  • GrzegorzM Profile Picture
    18 on at

    I get the idea, but it would help a lot if you could post the printscreen with expanded loops sections - the formulas are key here 🙂

     

    Thanks a million!

  • Community Power Platform Member Profile Picture
    on at

    Here they are

    extended conditions.PNGnog meer.PNG

     

  • SimonH Profile Picture
    8 on at

    thanks peter,

     

    As I don't use Dynamics I ended up using a Variable action instead. Initialise a varibale outside the for each and setting it to the initial value target output converted to text in this cse), then in the loop, set the variable with the upated value.

    Capture.PNG

     

    this works great if you want to replace the text with the same value (or in this case remove it) but I'm wondering if instead of an array you could use a json, where you find the 'key' then update it with the value.

  • GrzegorzM Profile Picture
    18 on at

    Simon, could you please post the formula you have in replace(...) ? If I understand well, I need to refer to replace text in the 'textfeed' variable, but not really sure how to refer to content of this variable?

  • GrzegorzM Profile Picture
    18 on at

    Thanks Peter for initial solution, and thanks Simon for your printscreens. I managed to figure this out also for my flow.

     

    For anyone who is interested, here are the 2 formulas you need:

    • createArray('&','_',',','.',';',':','/','"','"','!','@','$','%','^','+','=','\','|','<','>','{','}')
    • replace(Variables('textfeed'),item(),'')

    And also the printscreens of my solution.

    2017-11-20 13_54_52-Edit your flow _ Microsoft Flow 1.png

     

    2017-11-20 13_56_01-Edit your flow _ Microsoft Flow 2.png

     

     

  • MichaelS66 Profile Picture
    22 on at

    You can use replace within replace. I used this to remove illegal character in email subject. Not pretty but it works.

    replace(replace(replace(replace(replace(replace(replace(replace(replace(triggerBody()?['Subject'],':',''),'%',''),'#',''),'*',''),'<',''),'>',''),'?',''),'/',''),'"','')

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard