Assign Validation Error - Why?

studio

#1

I have an Assign activity in my workflow that is not working, but I really don’t understand why.

GenericVariable = GenericVariable.ToString.Trim.Replace("TBD","")

The validation error reads:

Cannot assign from type ‘System.String’ to type ‘UiPath.Core.GenericValue’ in Assign activity ‘Assign’.

The really frustrating thing is that this was working, but then tired adding a second Replace argument and then the validation error showed up. However, after I removed that the error would not go away. Even after clearing out the entire assignment and then rewriting it, still getting the error.

Help?


#2

Hi,
In your statement
GenericVariable1 = GenericVariable2.ToString.Trim.Replace(“TBD”,"")

GenericVariable2.ToString.Trim.Replace(“TBD”,"") This statement return String Value only…
So, you Need set GenericVariable1 as String

Regards,


#3

I cannot reproduce your issue. Could you please upload a minimal workflow showing the problem?
You may try deleting the variable (in the variable panel) and then re-creating it.

Adrian.


#4

I tried deleting and re-creating, and that did not fix the issue either. In order to get around the issue, I did end up making the variable a string, as I couldn’t find anywhere else in the workflow that required it to be a GenericValue.


#5

what version of UiPath do you use?


#6

I guess this is sporadic. I got the same error this morning when I tried to modify the text value assigned to a GenericValue variable in 2016.2. I tried for the second time (delete activity and drag and drop assign) , I did not get this error.

I got this error when I clicked on Value property of Assign and try to edit there. I did not get the error when I directly modify in Assign (Just observation may not be a clue).

image


#7

image

genType.xaml (5.4 KB)


#8

Studio 2017.1.6435 Enterprise Edition

Windows 10 Enterprise 64-bit
.NET 4.0.30319.42000


#9

Sometimes validation errors occurs when changing the type of variables.

I downloaded your workflow and all I did was to Ctrl+X cut the string “abcd efg…” . Then I pasted it back and the validation error disappeared.

Adrian.


#10

As I said earlier, the issue is sporadic. Sometime Ctrl+X also doesn’t work until you drop the new activity and assign the same value.

It might be confusing for the users when something is working all this time and suddenly giving the error.


#11

OK, so I had to change the original variable back to generic - the datatable is thowing an error when it is set as string. So here’s the current state of the issue:

GenericVariable = GenericVariable.ToString

No validation error

GenericVariable = GenericVariable.ToString.Trim

“Cannot assign from type ‘System.String’ to type ‘UiPath.Core.GenericValue’ in Assign activity ‘Assign’.”

This one is pretty frustrating, and I did delete the assign and start it all over again after modifying the variable; still got the error.


#12

I have the same error.

First I do a scrape from SAP and UIPath assign the scraped value to a GenericValue variable.

Then I try to convert the value to a string variable in order to replace a character. Nevertheless I got the same: “Cannot assign from type ‘System.String’ to type ‘UiPath.Core.GenericValue’ in Assign activity ‘Assign’.”


#13

@dgbaenar
Can you use a String type variable on the left side of the Assign instead of a Generic? You are getting that error because when you use .ToString (to Replace something) it becomes a string type; both sides need to be the same type of variable.


#14

This actually came up in a Helpdesk ticket that I had as well - it’s a known issue in the Assign activity. Go into variable editor, change type to string, and click outside of variable editor. Then, if you need it to be generic, go back into variable editor and change back to generic. The error will no longer exist when you change it back to generic.


#15

Thank you ClaytonM and jcarr79, I solved the issue as you said :slight_smile: