cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
roxanamoraru
Frequent Visitor

Convert the output into string

Hello, 

I have a situation. 

I'm trying to send an email - only to the peoples in share point list- each user will receive an email that contains a table with the items assigned. 

roxanamoraru_0-1670918388439.png

roxanamoraru_1-1670918445029.png

the flow was working until I added the " Start and wait for an approval"...  now I can send the email only if I write manually the email 

 

Before adding the approval step in the To: field  I added the output from "compose unique emails" and it worked perfectly well.

 

roxanamoraru_2-1670918636920.pngroxanamoraru_3-1670918656085.png

 

roxanamoraru_4-1670918666527.png

 I've tried to convert the output into a string to add it in the send email step  in To: field but that didn't worked... so I deleted it and run it again with the simple output in the TO field.. and this is the error 

roxanamoraru_5-1670919163287.png

That type of data does "Send an email " accepts in to field... I understand that it can't be an array.  But how I convert the output in something acceptable. 

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Amit_Sharma
Solution Sage
Solution Sage

Hi @roxanamoraru , please try below expression 

join(xpath(xml(json(concat('{ "root": {"emails": ', outputs('Compose_Unique_Emails'), '}}'))), '//emails//text()'), ';')

 

View solution in original post

12 REPLIES 12
Sundeep_Malik
Super User
Super User

Hey @roxanamoraru 

 

Currently you are sending this to the send email:

 

[

{ "UserEmail": "abc@gmail.com"}

]

 

Instead you just have to send abc@gmail.com

 

To do this, in the send email instead of writing outputs:

 

write a similar expression:

 

outputs('NameOfYourEmailCompose').UserEmail

 

Hopefully this would work. 🙂

 

 

I am doing something wrong ? 

roxanamoraru_1-1670922858699.png

 

 

roxanamoraru_0-1670922834875.png

Thanks!

Sundeep_Malik
Super User
Super User

@roxanamoraru 

 

No its fine, I knew this error would come. Let me try it on my end, I will give you the exact expression in a few minutes. 

Sundeep_Malik
Super User
Super User

@roxanamoraru 

 

Can you show compose unique emails action in edit mode? If not try this thing:

 

In that only, write 

currentexpressionthatyourareusing.UserEmail

By this you dont have to penetrate inside the array. 

 

There are two other ways too, but that will create an extra apply to each. Hopefully the above works. 

Amit_Sharma
Solution Sage
Solution Sage

Hi @roxanamoraru , please try below expression 

join(xpath(xml(json(concat('{ "root": {"emails": ', outputs('Compose_Unique_Emails'), '}}'))), '//emails//text()'), ';')

 

This is the compose: 

roxanamoraru_0-1670924611609.png

 

This is the flow: 

 

roxanamoraru_1-1670924670088.pngroxanamoraru_2-1670924734359.pngroxanamoraru_3-1670924761459.png

 

fchopo
Super User
Super User

Hi @roxanamoraru 

I would do the following:

1) Add another Parse JSON action to get the email values with the following schema:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "UserEmail": {
                "type": "string"
            }
        },
        "required": [
            "UserEmail"
        ]
    }
}

 

2) Append each email value to a semi-colon separated string

3) Use this string to send an email

emails-json.png

 

Hope that helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Thanks, 

This works!! 

roxanamoraru_0-1670925079786.png

 

But if I want to send separated email to people? Each person to receive the table with their items assigned? How I write the expression? 

 

Thank you so much !

Sundeep_Malik
Super User
Super User

@roxanamoraru 

 

In that just write:

 

union(body('Select_Emails').UserEmail,body('Select_Emails').UserEmail)

 

And then just pass the output in the send email of this action.

 

I am sure this would work, if this does not, you can try @fchopo method's too, I was gonna suggest that method next. You can try @Amit_Sharma approach too, that looks the easiest, I am not good with xml so I have no idea about it. 

thank you so much for your time and help !!

Thank you so much !!

Amit_Sharma
Solution Sage
Solution Sage

Hi @roxanamoraru , If you want to send only assigned items to users then this might not work. Instead do the below modifications

1. Loop of all the emails one by one.
2. Filter items specific to the current email 
3. Send email.

PS: I haven't followed the whole thread closely and may be wrong.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,459)