.rawValue format when using e-mail button (JavaScript help)

Avatar

Avatar
Ignite 1
Level 1
Michael14W
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
Michael14W
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
Michael14W
Level 1

18-09-2020

Hi

 

I have a form that users can enter text into a Text Field allowing multiple lines. For example:

 

"Paragraph 1 Text

 

Paragraph 2 Text"

 

I then have a button that sets up a draft e-mail and extracts the user entered text into the body of the e-mail, however it excludes the formatting. It comes out like ""Paragraph 1 TextParagraph 2 Text" (no spaces/enters)

 

The JavaScript I'm using has .rawValue but is there something else I can use? I've tried .formattedValue and .Value with no luck!

 

Example:

var Comment = this.resolveNode("form1.Page1.subformComments.txt_Question").rawValue;

.....

var cBody = "Dear team" + "\n" + "\n" +
"User entered text:" + Comment + "\n";

 

 

 

Replies

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

12-10-2020

The rawValue is already fine. The spaces and linebreaks shouldn't be removed. If they are removed anyway then because of something else, that's going on in the form. Can you share it?

Avatar

Avatar
Affirm 100
Employee
Kosta_Prokopiu1
Employee

Likes

165 likes

Total Posts

371 posts

Correct reply

107 solutions
Top badges earned
Affirm 100
Validate 1
Establish
Give Back 5
Give Back 3
View profile

Avatar
Affirm 100
Employee
Kosta_Prokopiu1
Employee

Likes

165 likes

Total Posts

371 posts

Correct reply

107 solutions
Top badges earned
Affirm 100
Validate 1
Establish
Give Back 5
Give Back 3
View profile
Kosta_Prokopiu1
Employee

13-10-2020

Here is my guess: you are using mailto: to start the mail client and provide the &body in the URL?

In that case you need to encode the newlines differently such as

mailto:test@test.test?body=Dear team%0D%0DUser entered text: %0Dp1%0Dp2%0D%0Dp3%0D

If that is true try it like that:

 

var text = "mailto:test@test.test?body=Dear team" + "\n" + "\n" +
"User entered text: \n" + Comment + "\n";
cBody = text.replace(/\r?\n|\r/g,"%0D");

 

Avatar

Avatar
Ignite 1
Level 1
Michael14W
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
Michael14W
Level 1

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
Michael14W
Level 1

05-11-2020

Thanks for your suggestion!

 

We managed to work it out in the end. The issue was that under Object > Field, we had set the field format to 'Plain Text' rather than 'Rich Text'. Changing that fixed it.