Unable to cast object of type 'System.Char' to type 'System.String'

I am having trouble with the typeargument and running without error. I have a for each (see screenshots below) and have type argument as string in the for each activity. The input of this is from an excel file.

What typeargument do I need to use? I have used several, including Int32, Object, System.String, etc. to no avail. Also, for reference, I am using an assign above this for each to assign the correct row to the ‘FailureModeArray’ variable.

Thanks.

Hi @tp39165

Check out this thread

Regards

@tp39165
Please prove the details of what data does your failuremodeArray contains

what is datatype of failuremodearray if it is string please change it to Array[String]
then give the type argument as string

if your failuremodearray is string you want to iterate it then give type argument as system.char

yes, I have checked that out before posting this and am not sure where I should use the get_txn.tostring… In the Assign?

I have a list of things in one column such as 1,2,3,4 and UiPath will do the automation for 1, then 2, then 3, then 4 in that row before moving on to the next row in the excel sheet.

I have FailureModeArray Variable with variable type String and Scope Sequence for reference

failure mode array is taken from an excel spreadsheet and has multiple items it should iterate on before moving to the next row. For example:

row 1: location A ---- dog, cat, giraffe
row 2: location B ---- car, computer

In that example, it will go to location A, iterate and do so tasks for dog, then the same for cat and giraffe. It will then go to location B in row 2 and do the same iterations for car and computer and so on

Hi @tp39165

Once try deleting the For each activity and giving that again. Change the Type Argument to System.String and I hope FailureModeArray is of DataType Array(System.String).

If you still face any error, post it here, I will help you out.

Regards

I have updated FailureModeArray variable type to System.String (clicked Array of [T] and then system.string. I am not getting an error in both the assign activity and type into activity where I use the ‘item’.

The error for the type into says "Argument’Text’: Compiler error(s) encountered processing expression “item”: Value of type ‘1-dimensional array of String’ cannot be converted to ‘String’.

The error for the Assign says: "Argument ‘Vaule’: Compiler error(s) encounterest processing expression “CurrentRow(“Recommendation”).ToString”. Value of type ‘String’ cannot be converted to ‘1-dimensional array of 1-dimensional array of String’.

Hi @tp39165

Can you specify what do you get in FailureModeArray varaible.

Regards

The recommendation column

Hi @tp39165

After you take the recommendation column, there are two in 2nd row, then what do you do?

Regards

@tp39165

You have an array containing details like
location A ---- dog, cat, giraffe
location B ---- car, computer
This is the array data you want it to get the dog and iterate and then cat and perform task and so on .

Then you have to do the process Like

For each row in Array
// In your current item you get -----> location A ---- dog, cat, giraffe
#You have to split it and get ------->dog, cat, giraffe
myStringVariable=row.ToString.Split({“----”}, StringSplitOptions.RemoveEmptyEntries)(1).Trim()
Arrayitems=myStringVariable.Split(","c)
For each

Here you get the single items as cat dog and so on

It will process the 1st row, then go to the next location (combination of the second and 3rd columns), and do the same process for GLB-AX-FE-DF-01 then GLB-AX-FE-DF-02 and then go on to the 3rd row and to the same until complete

Hi @tp39165

Since FailureModeArray= CurrentRow("Recommendation").ToString
Use the below syntax in Assign:

arr_Reccomendation= FailureModeArray.Split(","c)

arr_Reccomendation is of DataType Array(System.String)

After this use For each loop to iterate through arr_Reccomendation variable and complete the remaining process.

Post your queries in case of any difficulties

Regards