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.
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.
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.
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).
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.
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’.”
@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.
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.
lowerDN variable is a Generic type and to the right I am converting it to a ‘5 digit’ number by padding as many 0s to its left. But, this error shows up when I connect the workflow. What can i do here?
Hey. To be honest, I would just change your Variables to a String Type rather than a Generic Type, and since you won’t be performing any math on those values they can be strings.
When I change it to a string, it gives another error on the get row item where I get lowerDN. It says: Invalid L-value expression. Reference expressions cannot end with conversion. Expression’s type must exactly match the type of VB reference .