Lesson 3 practice 2 assigning issue


#1

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)


#2

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

Regards
Balamurugan


#3

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


#4

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


#5

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.


#6

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)


#7

Hi @charliefik,
Take a look

Regards
Balamurugan


#8

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


#9

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


#10

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


#11

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

Regards
Balamurugan