Lesson 3 practice 2 assigning issue

Hi All,

Trying to do Lesson 3 Practice 2

https://academy.uipath.com/lms/index.php?r=player&course_id=1&coming_from=lp&id_plan=22#training

and I get an error message when I try to assign a string to a generic variable

image

Says "Cannot assign from type System.string to type UiPath.Core.GenericValue’ in assign activity.

I thought that the point of generic variables is that they can take any type so shouldn’t this work?

I’m probably doing something very silly but can’t see what so any help would be greatly appreciated.

I’ve attached the xaml file if that helps.

Many thanks,

Main.xaml (7.2 KB)

Hi @charliefik,
you can assign the value to Generic variable like below

Regards
Balamurugan

@charliefik, I just deleted the value from the assign activity and added it back. It worked and i was not getting the error again.

Thanks,
Rammohan B.

2 Likes

@charliefik
Yes @Rammohan91 is also right. It is also working…
Regards
Balamurugan

Thanks very much for that fix.
So to confirm my understanding, basically what I was doing was correct there was some mysterious reason that it wasn’t working and deleting and then putting it back exactly the same way fixed it? That seems like a nightmare debugging situation if the fix is to do exactly what you were doing already how can you understand what you are doing wrong? Just trying to get my head around how to fix stuff in the future that may not be as simple.

1 Like

Hi,

Thanks for the suggestion about converting the string to a generic type but surely the point of a generic type is that you can pass anything to it and it doesn’t need to be converted (or am I not understanding properly)

Hi @charliefik,
Take a look

Regards
Balamurugan

Thanks for the link Balamurugan. I looked at the information (which I thought confirmed what I believed, maybe I’m still wrong?) but my point was that if I am passing string data to a generic variable I shouldn’t have to convert it (as you suggested) to a generic type before assigning it to a generic variable (as it should accept any type).

1 Like

Hi @charliefik ,
Yes . it accepts any type variable. but have to remind the red block.

image

better when assign the Generic variable to a variable .we can have to convert it like

image

Regards
Balamurugan

1 Like

Yes very good point thanks for the clarification. Although in this specific case I think the problem was slightly more mysterious (as deleting and replacing with exactly the same ‘code’ fixed the issue) but I will definitely bare that in mind going forward.

Thanks very much

1 Like

Hi @charliefik
Ok . All the best to clear all exams with certifications.

Regards
Balamurugan

Why is a resolution to an error message the action to deleting and replacing with exactly the same ‘code’ ??

I have seen this several times where the little exclamation signs don’t refresh (and disappear) unless the value is completely removed and re-pasted. So you are not currently doing anything wrong, although at some point prior you may have been, causing the initial exclamation mark, but then for some reason fixing the issue is not enough and the value needs to be removed completely and replaced.
Therefore the fix is to delete and replace. You can wait for the platform to be fixed but if you encounter this issue try removing the value completely and replace.