Assign Validation Error - Why?

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?

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,

1 Like

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.

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.

what version of UiPath do you use?

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

2 Likes

image

genType.xaml (5.4 KB)

1 Like

Studio 2017.1.6435 Enterprise Edition

Windows 10 Enterprise 64-bit
.NET 4.0.30319.42000

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.

1 Like

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.

1 Like

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.

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’.”

@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.

1 Like

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.

1 Like

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

Hi @ClaytonM , I have a similar error.

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?

Thanks.

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 .

Wait. I deleted the variable and created it again. It worked.

1 Like

The same thing happen with me