I am using this process to compare two excels. Inside a for each, i have an assign:
dtDefendants.Select(“Defendant = '”+CurrentRow(“Defendants”).ToString.Replace(“’”,”’’”))
When i run this process, it fails with the error: Assign: The expression contains an invalid string constant: 'Admiral Security Services Inc.
('Admiral Security Services Inc. is the name in the cell from the excel). Not sure what this error means or how to fix.
Anil_G
(Anil Gorthi)
April 10, 2023, 4:24pm
2
@atarantino
I guess you missed a single quote at the end
dtDefendants.Select("[Defendant] = '"+CurrentRow("Defendants").ToString.Replace("'","''") + "'")
You can as well use like this first check if you are getting any rows
DtDefandants.AsEnumerable.Where(function(x) x("Defendant").ToString.equals(currentrow("Defandants").ToString)).Count>0
And to get values into table
DtDefandants.AsEnumerable.Where(function(x) x("Defendant").ToString.equals(currentrow("Defandants").ToString).CopyToDataTable
You can as well use a filter datatable activity
Cheers
ushu
(Usha kiranmai)
April 10, 2023, 4:35pm
3
Yes I believe that is what the problem was. I added the + “'”) to the end and it bypasses that error but gives me a new error (on the same assign) for:
Assign: Syntax error: Missing operand after ‘s’ operator.
I think that the results in my excel column are written with an ’
(i.e., Gregory’s Bar)
How do i account for results with an ’ ?
1 Like
Anil_G
(Anil Gorthi)
April 10, 2023, 4:56pm
5
@atarantino
You are using a replace already…please check if the single quote you gave is same as you are getting it in the input
.Replace("'","''")
Or if there are any other special characters
cheers
Yes the input is a word that has 's at the end of it. There are no other special characters in the cells in that column.
Anil_G
(Anil Gorthi)
April 10, 2023, 6:52pm
7
@atarantino
Yes replace should be taking care…can you show a screenshot of what you used please
Or if you can attach a input file or xaml you ar eusing would help
Cheers
Here is the .xaml
Main.xaml (42.2 KB)
heres a sample of the file i’m running through.
test.xlsx (12.0 KB)
Anil_G
(Anil Gorthi)
April 10, 2023, 7:33pm
9
@atarantino
When I Open I see this error…may be you copy pasted the replace…please remove the double quotes and single quotes and retype them again in the editor of UiPath
I just tested the same formula on your file and it threw no error once I replaced those inverted comma
cheers
Nitya1
(Nitya Tomar)
April 10, 2023, 7:37pm
10
dtDefendants.Select(“Defendant = '” + CurrentRow(“Defendants”).ToString.Replace(“'”, “‘’”) + “'”)
system
(system)
Closed
April 14, 2023, 3:38pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.