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

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

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

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

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (2,110)