cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tested1
Level: Powered On

coalesce the first 100 characters of an email with a planner task

Hello!

 

Could you please help me with this formula 😞

 

I want to get the first 150 characters from an email, and then a planner task is created with the first 150 characters of the email in the 'title' of the planner task.

 

The formula works fine for emails under 150 characters. But then fails if the email is longer saying Schema validation has failed. Validation for field 'Title', on entity 'Task' has failed: The field cannot be longer than 255 characters. on the create a task option.

 

Please see pic. How could I limit the coalescn option to only get the first 150 chars?

 

I got the reasoning from this thread Click here 

 

thanks! image.png

8 REPLIES 8
tested1
Level: Powered On

Re: coalesce the first 100 characters of an email

Any help pls 😞 Originally I used substring function but that started failing recently randomly.

tested1
Level: Powered On

Re: coalesce the first 100 characters of an email

Or does anyone else have any other methods to get the first say 150 characters of an email, and put it on the title of a new task created? 

 

 

Community Support Team
Community Support Team

Re: coalesce the first 100 characters of an email with a planner task

Hi @tested1,

 

I think you have a misconception about coalesce() function. This function is to return the first non-null value from one or more parameters, the expression coalesce(body('Html_to_text_2'),0,150) will return all the output of Html_to_text_2 action.

 

The best method is to use the substring() function, but at the following reply you said it fails randomly, could you please share the failed history of your Flow?

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tested1
Level: Powered On

Re: coalesce the first 100 characters of an email with a planner task

Hello @v-litu-msft  

 

Thank you for reply!!

 

Originally I used the formula below - substring body html to text. This worked fine for a few months then I randomly got the error 'InvalidTemplate. Unable to process template language expressions in action 'Create_a_task' inputs at line '1' and column '2679': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'.'

 

I just  deleted the coalesce formula and put the substring one back in and it seems to be working now! So random... No idea why it stopped working but now it seems to work again

 

image.png

Community Support Team
Community Support Team

Re: coalesce the first 100 characters of an email with a planner task

Hi @tested1,

 

I haven't met the substring expression not work. If it not work, the method to solve it is to recreate it as usually.

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tested1
Level: Powered On

Re: coalesce the first 100 characters of an email with a planner task

Yeah strange. 

 

It was because of this thread https://powerusers.microsoft.com/t5/Using-Flows/Problem-with-Flow-to-sync-Outlook-Calendar-event-to-...

 

Thatt someone linked to me about substring failing and coalesce saving them. But hopefully no issues now!

Highlighted
barret
Level: Powered On

Re: coalesce the first 100 characters of an email with a planner task

The substring function will fail if the length of the substring you are trying to get is longer than the length of the text you are pulling the substring from. For example, if you do a substring(0,100) and the length of the string is only 50 characters, the substring function will fail with an error message like you see below. To use substring, you must first check the length of the string to see how long it is and make sure your substring function doesn't seek beyond that length.

tested1
Level: Powered On

Re: coalesce the first 100 characters of an email with a planner task

Hello @barret 

 

That makes sense! I had no idea why it kept failing.

 

I will check the email if it was less then 150 chars and thus failed. If its common I'll shorten the string to say 0-50 chars which should always be satisfied 🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 205 members 5,463 guests
Please welcome our newest community members: