Showing results for 
Search instead for 
Did you mean: 
Helper V
Helper V

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



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

Helper V
Helper V

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

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
Community Support

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.

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



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.

Yeah strange. 


It was because of this thread


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

Responsive Resident
Responsive Resident

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.

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

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,813)