How to Manage the double quotes in variable

Hi Team,

1.I have datatable from column “GL Text” in which having value (“TAXS” test.test2.bb)
-while reading datatable value is getting changed to
[GL Text
“”“TAXS”" test.test2.bb"
]
2.Reading the column = dtOutput.DefaultView.ToTable(False,“GL Text”)
3.converting the dt to string using output datatable activity
4.removing the header value = strOutput.Remove(0, strOutput.IndexOf(Environment.NewLine)+2)
-double quotes are getting added while converting the dt to string
@“”“”“”“TAXS”“”" test.test2.bb""
"
5.Set to clipboard and paste the value to SAP. value which should be pasted in sap is = “TAXS” test.test2.bb

Regards,
Deepsikha

@deepsikha.kushwaha

image
image
image

Code in the assign activity

strcell = dt(0)(0).tostring

In the same manner if your datatable is from excel and you knw the cell address you can fetch it. If the datatable is dynamic you can use a for loop and an if condition to assign a varaiable with the value of the cell.

The value isn’t being changed. It’s just escaping the double quote when displaying the value.

@postwick is correct, @deepsikha.kushwaha your issue resolved now?

Or share the excel with GL Text Column!

Regards,
Ajay Mishra

Hi Ajay,

File format is xlsb, Unable to upload here.

Regards,
Deepsikha

And could you please check the same way I am doing -
1.reading from DT
2.convert it into string
3.copy it to set to clipboard and
4.then paste it to notepad.

Regards,
Deepsikha

image

@deepsikha.kushwaha i tried the steps you mentioned but i am getting your expected output check this file
API.xaml (9.8 KB)
image

Still not working for me.
can you read it from excel instead of reading it from build DT.

@deepsikha.kushwaha
its working for me with excel also please check code once
API.xaml (11.4 KB)

@deepsikha.kushwaha

  1. The first one when read from excel to datatable looks proper it is just escaping…
  2. Why are you converting datatable to string? Why not get the value you need directly?
  3. Clipboard also would not add more unless there is somethign else that is hopening in between

Cheers

1. Escaping Double Quotes:

If you want a double quote to be part of the variable’s value (e.g., a string containing a quote), you need to escape it. UiPath uses double quotes itself to define strings, so a single double quote within the string would be interpreted as the end of the string. Here’s how to escape it:

  • Double the double quote: You can simply use two double quotes together (“”). For example, if you want a variable named “message” to hold the value “This is a message with a quote “inside” it.”, you would assign it like this:

message = "This is a message with a quote ""inside"" it."

2. Using Chr Function:

Another way to escape a double quote is by using the Chr function. This function takes the ASCII code of a character and returns the character itself. The ASCII code for a double quote is 34. So, you can use the following:

message = "This is a message with a quote " & Chr(34) & "inside" & Chr(34) & " it."

3. Concatenation:

If the variable you want to use already contains double quotes, you can simply concatenate it with another string using the + operator. For example:

var1 = "This is the first part" var2 = " with a quote" finalString = var1 + var2 + "."

Choosing the Right Method:

The best method depends on your specific situation. If you’re building a string with a single embedded quote, escaping with a double quote is the simplest way. If you’re working with pre-defined variables that might contain quotes, concatenation or the Chr function might be more suitable.