Writing one variable in single line in Write Line activity

Hi All, I am passing one variable(ErrorMsg) in write line activity which has value as mentioned below but instead of coming in one line it’s chaotic here, I want all the values to come in one line only. Please help…thank you in advance …

Write line: ErrorMsg

E.g.

Error during proxy processing
An exception with the type OPQ occurred, but was neither handled locally, nor declared in a clause
The database returned a value containing an error

Error during proxy processing
An exception with the type ABC occurred, but was neither handled locally, nor declared in a clause
The database returned a value containing an error

Hi @anjasing,

Try this
ErrorMsg.GetText().Replace(Environment.NewLine, " ");

1 Like

HI What is Data type of Error Msg here? I tried but it’s giving issue…for me error message is in form of string

yes, it should be in form of a string.

Thank you soo much. It’s working.
ErrorMsg.Replace(Environment.NewLine, " "); this works for me

Hi Sangeetha, it’s not working and get text is giving issue of getText is not a member of string.

Hi @anjasing ,

What is the Data type of ErrorMsg variable ?

Hi @anjasing,

Surround your workflow with “Try Catch” Activity then get error message with string then replace error message.

plz check attached workflow

Main1.xaml (10.9 KB)

Thanks,
Rajkumar

Hi, It’s string

Hi @RajKumar_DC , I don’t want to use it in Try Catch, can u plz suggest some other way!

@anjasing

Sorry without capture error message with variable we not do any thing

Thanks,
Rajkumar

@anjasing ,

If the Error message is already contained in the ErrorMsg variable which contains data in the form of multiple lines then we can use the below Expression to combine the Splitted lines to a Single line :

String.Join(" ",Split(ErrorMsg,Environment.NewLine).ToArray)

Let us know if this doesn’t work.

Sorry, it didn’t work

For all future readers, I’ve found one solution that worked for me:
System.Text.RegularExpressions.Regex.Replace( InputValue.Trim,“\n”," ")

Hope it help somebody! :slight_smile:

Thanks everyone for helping … :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.