2207
Views
13
Comments
Newline() shows \r\n
Question

Hi,

I am exposing rest api where i am generating an error. I am using newline() fn but during render it turns into \r\n. I have used char(10) also, it further renders into \n.

Any suggestion how to introduce new line.


Regards,

Virat

2025-12-23 12-24-14
Adão Pedro

virat kohli wrote:

Hi,

I am exposing rest api where i am generating an error. I am using newline() fn but during render it turns into \r\n. I have used char(10) also, it further renders into \n.

Any suggestion how to introduce new line.


Regards,

Virat


Hi, after writing the error message with the newline() do  URLEncode()

encode.PNG
UserImage.jpg
virat kohli

Adão Pedro wrote:

virat kohli wrote:

Hi,

I am exposing rest api where i am generating an error. I am using newline() fn but during render it turns into \r\n. I have used char(10) also, it further renders into \n.

Any suggestion how to introduce new line.


Regards,

Virat


Hi, after writing the error message with the newline() do  URLEncode()


Not working. It turns into %0d%0a

2025-12-23 12-24-14
Adão Pedro

virat kohli wrote:

Adão Pedro wrote:

virat kohli wrote:

Hi,

I am exposing rest api where i am generating an error. I am using newline() fn but during render it turns into \r\n. I have used char(10) also, it further renders into \n.

Any suggestion how to introduce new line.


Regards,

Virat


Hi, after writing the error message with the newline() do  URLEncode()


Not working. It turns into %0d%0a


can you share oml, or images to try to understand how you are doing?

2026-01-19 17-09-56
Carlos Lessa
 
MVP

virat kohli wrote:

Hi,

I am exposing rest api where i am generating an error. I am using newline() fn but during render it turns into \r\n. I have used char(10) also, it further renders into \n.

Any suggestion how to introduce new line.


Regards,

Virat

Hi Virat, can you give us more detail of what are you trying to achieve, pic or/and logs of the errors, the oml perhaps, cheers.


UserImage.jpg
virat kohli

{

    "Errors": ["Atribute 1 is mandatory\r\nAtribute 2 is mandatory"],

    "StatusCode": 500

}

Getting the error in above format.

Demo.oml
2026-01-19 17-09-56
Carlos Lessa
 
MVP

virat kohli wrote:

{

    "Errors": ["Atribute 1 is mandatory\r\nAtribute 2 is mandatory"],

    "StatusCode": 500

}

Getting the error in above format.

please try with Chr(13) + Chr(10).


2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Virat,

it's perfectly normal that a newline becomes an \r\n in the JSON / result text variable.  If you consequently use it in an OS screen in a expression or TextArea widget, the newline is neatly respected.

Maybe you want to show it with the msg node.  In that case newline doesn't work.  See attached oml.

By default, the msg node doesn't respect either newline characters, or <br> html element.  But you can call the message code through javascript, and have 3rd parameter on true, in that case a <br> gets respected.

By the way, this is not related to you using a rest api, if you use a simple server call, this behaves exactly the same.

See attached oml,

Dorine 


EDIT : as for the reason it doesn't work in the msg popup, that's beyond my understanding, it probably has something to do with it being shown in a div, whereas in an expression or textarea, it's shown in a span.  But that's just a wild guess of mine.

DemoNewlineInMessage.oml
UserImage.jpg
virat kohli

@carlos,

It is not working. I have attached the demo.oml in my previous reply. One more thing, i am calling rest api from outside.

https://reqbin.com/

2026-01-19 17-09-56
Carlos Lessa
 
MVP

virat kohli wrote:

@carlos,

It is not working. I have attached the demo.oml in my previous reply. One more thing, i am calling rest api from outside.

https://reqbin.com/

check this answer this is a problem exactly or very similar to yours

UserImage.jpg
virat kohli

Carlos Lessa wrote:

virat kohli wrote:

@carlos,

It is not working. I have attached the demo.oml in my previous reply. One more thing, i am calling rest api from outside.

https://reqbin.com/

check this answer this is a problem exactly or very similar to yours

How to call java script widget in server action?


2026-01-19 17-09-56
Carlos Lessa
 
MVP

virat kohli wrote:

Carlos Lessa wrote:

virat kohli wrote:

@carlos,

It is not working. I have attached the demo.oml in my previous reply. One more thing, i am calling rest api from outside.

https://reqbin.com/

check this answer this is a problem exactly or very similar to yours

How to call java script widget in server action?


you can use:


and add your script inside

UserImage.jpg
virat kohli

@carlos,

I already tried this option by passing following string:

Result.Error = EncodeJavaScript(If(Trim(Result.Error)="","Atribute1 is required",Result.Error+"\nAtribute1 is required" ))

But it gives me empty string. Might be i am not using in right way.

2026-01-19 17-09-56
Carlos Lessa
 
MVP

Hi Virat, I know that isn't what you want but can help you to get the format you need:

Instead of raising an exception, deal with the message on client-side, use the API: 

SyntaxEditor Code Snippet

$public.FeedbackMessage.showFeedbackMessage($parameters.ErrorMessage, 3, false, '', true);

and you can manage and show 2 lines on the feedback.

when you raise the exception you also encode the entire msg and your (newLine(), <br/>, \r\n, etc) will become text and will get the behave we got until now.

You can see in the photo


I attached the oml, check if you can use this idea to achieve your goal

Hope I could help you.

Best regards

Carlos Lessa

Demo1.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.