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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / PAD String.Format syntax
Power Automate
Answered

PAD String.Format syntax

(0) ShareShare
ReportReport
Posted on by 79

Hi

I have this syntax String.format(config("Email_Body").Tostring, ErrorMsg) from uipath to be converted to PAD usable

ErrorMsg is a variable

my config("Email_Body") read from excel as a html body as follow

<html>
<body>

<p>Hi All,</p>

<p><b>Fail</b> to run . </p>
<p>The error description: &nbsp;<b>{0}</b></p>
<p> Thanks & Regards, </p>
<p> Robot </p>

</body>
</html>

 

how can i change this syntax String.format(config("Email_Body").Tostring, ErrorMsg) so my email body  that {0} can be dynamic?
thanks

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @Zy_Sin 

    Please understand UIPath and power automate desktop both syntax are working in different ways. So please elaborate what you trying to achieve in your use case?

     

    Is UIPath having any email template in excel the same you want to use in power automate desktop?

    Please elaborate your issue?

  • Zy_Sin Profile Picture
    79 on at

    Hi Deenuji

     

    i have this email template that has a part that need to be dynamic which hereby i indicate it as {0}

    the {0} will be replace by a variable name "ErrorMsg"

    How should the syntax be? in Power Automate Desktop Sent email body?

    my email template is in html format

    <html>
    <body>

    <p>Hi All,</p>

    <p><b>Fail</b> to run . </p>
    <p>The error description: &nbsp;<b>{0}</b></p>
    <p> Thanks & Regards, </p>
    <p> Robot </p>

    </body>
    </html>

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @Zy_Sin 

    First create template like below using set variable option:

    Deenuji_0-1712831376529.png

     

    Then using replace text option you can replace {0} with actual error.

    Deenuji_1-1712831394134.png

     

    Finally assign html template variable into outlook send email body as highlighted below:

    Deenuji_2-1712831542207.png

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Zy_Sin 

     

    Another method where you can use String.Format method simmilar to in UiPath (advanced approach ) , 

    see below

     

    first set a variable like this

    Nived_Nambiar_0-1712850001795.png

     

    Now use Run .Net script action like below

    Nived_Nambiar_1-1712850026439.png

     

    set script parameters like this

    Nived_Nambiar_2-1712850053140.png

     

    Now use below code 

    Nived_Nambiar_3-1712850081159.png

     

    Now run the flow and see the output

    Nived_Nambiar_4-1712850103041.png

     

     

    Hope this helps 🙂

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you just want to send it as an email, you don't need any conversions or anything. Just pass in a variable into the template like this (assuming you have your dynamic part in %Variable%):

    <html>
    <body>
    
    <p>Hi All,</p>
    
    <p><b>Fail</b> to run . </p>
    <p>The error description: &nbsp;<b>%Variable%</b></p>
    <p> Thanks & Regards, </p>
    <p> Robot </p>
    
    </body>
    </html>

     

    You can either set this as a variable, or use it directly in your Send email action. Just make sure that when you use your Send email, you enable the toggle to use HTML body. Depending on the specific action, this may be disabled by default.

  • Zy_Sin Profile Picture
    79 on at

    Hi Nived_Nambiar,

    I put this {0} as a variable inside the .NET code to run but it throw as Expression expected error. Instead of your 'NN', i put it as %Err_Msg% and it throw Expression expected. 

    Zy_Sin_2-1712886023032.png

    Then i remove the %% and put it as  outputstring=string.format(inputstring,Err_Msg) and it throw as 'Err_Msg' is not declared. It may be inaccessible due to its protection level.

    Zy_Sin_3-1712886301354.png

     

    I am trying to replace {0} which is inside my config file to the variable that i set in PAD line 7 an error message (this line 7 is an example, in actual flow line 7 will be a variable that is derive from Macro run)

    Zy_Sin_4-1712886429761.png

     

    Thanks

  • Zy_Sin Profile Picture
    79 on at

    Hi Deenuji,

     

    Replace text works.

    I am puzzle how Run.Net script syntax would be.

     

    Thanks

  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Zy_Sin 

     

    one thing to remember , if you need to pass any variable from Power Automate Desktop to Run .Net script action, you have to pass it via script parameters, for passing %Error_Msg% variable, you have to create script parameter whose direction is In and then pass the the variable into it (Just like arguments in UiPath)

     

    see below for example 🙂

    Nived_Nambiar_0-1712890289535.png

     

    Nived_Nambiar_1-1712890304748.png

     

    Hope now you got a clear idea on this !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • Zy_Sin Profile Picture
    79 on at

    Thanks @Nived_Nambiar 

     

    Understood and it works.

  • Zy_Sin Profile Picture
    79 on at

    Hi @Nived_Nambiar 

     

    I have another issue for the above
    Actually the string.format for {0} is an output from my macro script, written as function.

    i am unable to output it as variable to PAD.

    is there a way to pass data out from macro into PAD?

    i have created a new topic under this heading

    "how to get output from Macro to be input to Email in PAD flow"

    but no one respond on that.

    Thanks

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 464

#2
Haque Profile Picture

Haque 416

#3
David_MA Profile Picture

David_MA 323 Super User 2026 Season 1

Last 30 days Overall leaderboard