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 / How to convert a varia...
Power Automate
Unanswered

How to convert a variable that contains (a variable in expression-code format) to the value of the stored variable?

(1) ShareShare
ReportReport
Posted on by 20

😲You are probabily thinking, "Huh?"

In short:
I have a Power Automate variable that contains the expression-code for a field or variable. 
I want to get the value of the expression-coded variable.

Example:

Variable Name: "Replace With"

Value: @{triggerOutputs()?['body/Author/DisplayName']}

🌟Some Magical Operation 🌟

Output: The value of the expression-coded variable: "Jones, Thomas K"

 

Here is what I'm doing:

I have email message text stored in a variable: "Email Body"

The text contains [TAGS] that need to be replaced with data from the triggered list record.

[Name] is replaced with Created By field value.

[DueDate] is replaced with Next Due Date variable value.

I created a "Tag-Data" list with all the Tags and the extension-coded variable to replace it:

[Name]  replaced with  @{triggerOutputs()?['body/Author/DisplayName']}

[DueDate]  replaced with @{variables('Next Due Date')}

 

The Flow (in English)

I have my message text (below) with the [TAGs] stored in the variable "Email Body":

"[Name], we need the information for [TaskName] by [DueDate] or your request will be canceled."  

For-Each item in my Tag-Data list:

  • The Tag is stored in the variable "Replace String
  • The Expression-code is stored in the variable "Replace With"
  • COMPOSE = Replace([Email Body], [Replace String], [Replace With]
  • Email Body = COMPOSE

End For-Each

 

The output I get is:

"@{triggerOutputs()?['body/Author/DisplayName']}, we need the information for @{variables('Task Name')} by @{variables('Next Due Date')} or your request will be canceled."

 

The output I want is:

"Jones, Thomas K, we need the information for End of Year Evaluation by June 7, 2022 or your request will be canceled."

 

Thoughts?  Also, if you can think of a better way to do this, I'd be glad to hear it!

 

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @CFlorian 

     

    Looks like you got an email template which you replace with certain values using replace() expression and some values you are generating with an expression. Thats the way I understood. There is nothing wrong in that. If you could store the values in a database then you can directly map the values in your email template. So its all depends on your business scenario. There is nothing wrong with what you done for the email template.

  • CFlorian Profile Picture
    20 on at

    So how do I convert the variable with variable code in it to the variable value?

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Not sure I understood correctly about variable code you mentioned. Have you got a flow which you can post a screenshot?

  • CFlorian Profile Picture
    20 on at

    The flow itself wont help

    I have a variable that contains the CODE for the variable with the information I need.  When I replace the tag [NAME] with the content of the variable I get the code for the variable "@{xxx}" and not the value of the variable (@{xxx})="Fred".

     

    Again, the basic issue:

    Flow Variable Name: "Replace With"

    variable contains this string: @{triggerOutputs()?['body/Author/DisplayName']}
    The variable code in the string is what I need the value from.

     

    When I display the "Replace With" variable: 

    • I get: : @{triggerOutputs()?['body/Author/DisplayName']}
    • I want: "Kirk, James T"

    How do I get the string "@{triggerOutputs()?['body/Author/DisplayName']}" converted to the output of that variable?

  • Verified answer
    CFlorian Profile Picture
    20 on at

    I didn't want to do it this way, but I ran out of time.  
    I wanted this function to be fully controlled from a list. To make this work, I added a SWITCH with a CASE for each [TAG] in the list.

    I would still love a real answer...

  • smathew1 Profile Picture
    4 on at

    Hi,

     

    Did you get any answer on this, I trying a similar thing, storing the expression in sharepoint list to be used in email content. It just bring the code as plain text , not the value. I am trying not to use the replace. 

     

    https://powerusers.microsoft.com/t5/Using-Flows/Dynamic-Email-content-in-SharePoint-list/m-p/1666298

  • VictorIvanidze Profile Picture
    13,073 on at

    Hi @smathew1, it looks like the only possible way I see is using a parent/child flows:

    https://learn.microsoft.com/en-us/power-automate/create-child-flows

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard