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 Automate
Unanswered

Replace expression

(0) ShareShare
ReportReport
Posted on by 391

I am trying to replace the string between src=\" and " style= with item()?['AbsoluteUri']. The reason I am doing this is because the embedded image from email body in SharePoint enhanced rich text column is showing as a broken image.

nicklim_8-1697755713105.png

 

My flow is showing as successful but the string wasn't replaced in "Update Item" with item()?['AbsoluteUri']

nicklim_9-1697755956114.png

nicklim_13-1697756224810.png

 

 

 

 

 

replace(outputs('Create_item')?['body/RichText'], first(split(last(split(outputs('Create_item')?['body/RichText'], 'src=\"')), '" style=')), outputs('Add_attachment')?['body/AbsoluteUri'])

 

 

 

nicklim_12-1697756064914.png

 

 

Am I missing something?

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,928 Super User 2025 Season 2 on at

    @nicklim 

     

    Id really have to see the full strings to be 100%, as for it saying it worked, worked doesn't mean it actually replaced anything, just that it didn't cause any errors.

     

    plus the \ looks like an escape character so you may not be able to replace it as if its a string. Again I'd have to see the entire string.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • nicklim Profile Picture
    391 on at

    Hi @FLMike 

     

    Sorry are you referring to the string of outputs('Add_attachment')?['body/AbsoluteUri']  or something else.

  • Michael E. Gernaey Profile Picture
    53,928 Super User 2025 Season 2 on at

    @nicklim 

     

    Hi :-), I am referring to the entire replace. If you were to put a compose before the SharePoint action and just build the string without the replace, what does it look like, please actually paste it here, but feel free to change the real address so we dont see it.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • nicklim Profile Picture
    391 on at

    Hi @FLMike 

     

    That is the compose of "Body" of the email before the SharePoint actions.

    "<html><head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style></head><body dir=\"ltr\"><div class=\"elementToProof\" style=\"font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:11pt; color:rgb(0,0,0)\"><img class=\"ContentPasted0 w-219 h-77\" size=\"6101\" data-outlook-trace=\"F:1|T:1\" src=\"cid:f7fbfcf2-f2ac-426d-ad42-c36f79b74dfa\" style=\"max-width:100%\"><br></div><div class=\"elementToProof\"><div style=\"font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:11pt; color:rgb(0,0,0)\"><br></div><div id=\"Signature\"><div><b style=\"font-family:Calibri,sans-serif; font-size:14.6667px; color:rgb(36,36,36); background-color:rgb(255,255,255)\"><span lang=\"EN-AU\" style=\"font-size:7.5pt; font-family:Arial,sans-serif; margin:0px; color:gray\">Nick Lim</span></b></div></div></div></body></html>"
  • Michael E. Gernaey Profile Picture
    53,928 Super User 2025 Season 2 on at

    Hi @nicklim 

     

    are you trying to replace it from the Entire String, or are you trying to replace it from the Split bla bla bla bla. Because your internal split is getting rid of that src=\, but your replace is based on the entire output, and then you are using a giant string to replace.

     

    So can you confirm did you mean this and I might have a typo in there, but the spirit should be clear. In your version, you are comparing your giant full string, to the partial string you are creating with the splits and then trying to replace something.

     

    That will make it NOT work how you expect it to.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

    replace(first(split(last(split(outputs('Get_item')?['body/RichText'], 'src=\"')) , '" style=')), outputs('Add_attachment')?['body/AbsoluteUri'])
  • nicklim Profile Picture
    391 on at

    @FLMike 

     

    I would like to replace the string between src= and style= with outputs('Add_attachment')?['body/AbsoluteUri']. That bit of string that starts with cid: is dynamic, whenever an email arrives and has embedded image, the string changes. 

    nicklim_0-1697766665078.png

     

    So if the replacement was successful, it might look something like this i think, that way it can display the image in the enhanced rich text column

    <img src=\"/sites/xxx/Lists/test/Attachments/14/image001.png\" style=\"max-width&#58;100%;\" /><br></div></div>",

     

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 323 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 183 Most Valuable Professional

Last 30 days Overall leaderboard