Practice 3 - Switch

Hi everyone!

I’m new in the community and i’ve issues with the third practice from the module of Variables, Data Type and Control Flow.

I’m stuck because I can’t use the method Substring in my Switch to select only the first and the second letter from the arrays.

There’s something wrong with my packages or extensions?

Here are my packages:
image

I appreciate all the help!

Hi @Lucas_Rufino,

Welcome to the community!

It is a simple fix.

In every for each you as the user will have to say what is the item. Is it a string or int or any other datatype.

In your case you don’t see the Substring method because by default every for each loop assigns a object type to its item.

You can fix this in any of the two ways.

  1. Use item.ToString.substring(with your params) in your switch condition
    Or
  2. In your for each you can set the item property to be string

In both cases basically you are telling UiPath that your item is of string type.

In the first string you let the item be an object but cast it to a string yourself.

Hope this helps clear your doubt. Good luck with your learning. :slight_smile:

Hi @Lucas_Rufino

Change the Arguments type(The Type of the ErrorCodes) in the properties of For Each
And try once

Regards,
Sudharsan

Make sure the TypeArgument for the For Each is set to String also.

The problem was the property of For Each.

Thank you all, guys!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.