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

html to text function adding random break lines issue

I am extracting email body then adding the data in a new raw in excel file, using the html to text first, then substring function to extract the needed data.
the issue is that the html to text function is inserting random break lines in the converted texts, the thing that is causing errors in substring function.
does anyone knows why and how the break lines are inserted in html to text function ? and how can i handle it ?

thanks,

 

Capture1.PNGCapture2.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Visitor

I found a solution:

convert the output of the html to text function to array using creatarray(), then converting it back to string using string(), and then removed the /n (break lines) from it using replace(), in this way substing() is not throwing errors.

hope this would be helpfull.

 

View solution in original post

5 REPLIES 5
Community Support
Community Support

Hi @OusB ,

 

What’s the error message you’ve got on your side?

 

Could you share more details on the functions?

 

What’ the format of the email body?

 

You mentioned that Html to text action adding random break lines, how is it displayed?

 

According to your description, I guess that you want to extract contents from the email body. I have made the following test for your reference.

 

The email is formatted likes below:

1.PNG

 

Trigger the flow by When a new email arrives, then the action Html to text.

 

To get Name, use the following code:

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Name'),5),sub(indexOf(body('Html_to_text'),'Date'),add(indexOf(body('Html_to_text'),'Name'),5)))

 

Using the following statement to get the Date:

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Date'),5),sub(indexOf(body('Html_to_text'),'Comments'),add(indexOf(body('Html_to_text'),'Date'),5)))

 

The similar configuration for the Comments:

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Comments'),9),sub(length(body('Html_to_text')),add(indexOf(body('Html_to_text'),'Comments'),9)))

 

Images for your reference:

2.PNG3.PNG

 

Best regards,

Mabel

 

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

thanks for your replay @v-yamao-msft , here are the answers to them:

 

- the error: Unable to process template language expressions in action 'Add_a_row_into_a_table' inputs at line '1' and column '2529': '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. 

- the function : similar to the context you shared.

- did not get your question about the email format: it is an outlook email, can you clarifu what details you need. 

- the break lines instered as the follwoing sample: in the original email, break lines are never like this, and they are changing randomly.  

 

Lead Contact: test test Organization: gefh Address: dsbsgb vsdvs dfvdf, dvdf
dfvfd United States Phone Number: (235) 457-4736 Email: vc@dfb.com Program/Event
Name: gedgvd Program/Event Timeframe: dvfvbzs Website:
https://clicktime.symantec.com/3PuPQyfz13i5NMBmC5D9vvJ7Vc?u=http%3A%2F%2Fdfg.com
Donation Type Request: Funding Dollar Amount: 1423 Does your organization
benefit Blue Diamond's neighborhoods?: Sacramento, CA Focus Areas: Agricultural
Education Health & Wellness Community Development Briefly describe your
organization and its mission. How is it administered?: dgbbrth Please attach a
copy of your most recent annual report.:

 

hope i could make the issue clearer.

 

 

Frequent Visitor

I found a solution:

convert the output of the html to text function to array using creatarray(), then converting it back to string using string(), and then removed the /n (break lines) from it using replace(), in this way substing() is not throwing errors.

hope this would be helpfull.

 

View solution in original post

I'm having this same issue, but it seems to me that HTML to Text is not adding the \n, its randomly adding a line break, and the then Parse JSON adds the \n for the line break.  How do I remove the \n from the Parse JSON outputs?  I can't use replace() as it expects a string and not an object from the Parse JSON.

JSON Input from html to text (notice line breaks)

{"Type_of_Request":"Name

Change","Rate":"$250.00","Date_Submitted":"2019-04-23 -

10-45-18-am",

 

JSON Output

"Type_of_Request": "Name\nChange",
"Rate": "$250.00",
"Date_Submitted": "2019-04-23 -\n10-45-18-am",

 

 

 

New Member

I was having this same issue where as I have a flow that accepts an email w/JSON formated data in HTML, performs html to text, then Parse JSON.  Nothing seemed to work for me to get the line breaks and subsequent \n out of my data.  The only thing that worked is inserting a <br> after each JSON data set within my code (php mailer) that generates the email.  The <br>'s then get stripped out by the html to text and no more random line breaks or \n.

 

$message = '{';
$message .= '"Type_of_Request":"'.$requestType. '",<br>';
$message .= '"Rate":"'.$rate. '",<br>';
$message .= '"Date_Submitted":"'.$datestamp. '",<br>';
$message .= '"First_Name":"'.$firstName. '",<br>';
$message .= '"Last_Name":"'.$lastName. '",<br>';
$message .= '"Email":"'.$userEmail. '"';
$message = '}';

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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!

Users online (8,100)