Build your first process - ERROR Index was outside the bounds of the array

Hi guys,

I’m trying to do the Get Started with RPA Development activity (the “Build your first process part 1”) and at some point it shows me the error “Index was outside the bounds of the array” but I’m using their excel file so I have no idea why that’s happening!

It runs fine until the “Jessie” line so I have no idea how to fix it! =(

You’re going to have to show us your activity that is failing, so we can help. We need details.




image

You have to use debug mode so it will stop on the activity that is faulting. Then show us that activity and its properties.

Hi @beatorres2
Simple you are putting First name and second but in row 5 and 7 you have no second name.
Here your string going out off Bond…put some dummy then run it.
It will run correctly.

When you are sipliting Name coloumn for First name its getting data but for second its going out of bond

Sol:
Put if condition
In condition put → row.item(“Name”).Split(" "c).Count.ToString =“2”

Then put Type into Last name activity in If-then block.

If I had to guess, it’s your “Type Into ‘Last Name’” activity with the split. You are specifically referencing index (1) but when there is no space in the Name, there is no array element with index (1). So index (1) is outside the bounds of the array.

You can have it check by using an advanced If:

If(Name.ToString.Contains(" “),Name.ToString.Split(” "c)(1),Name.ToString)

This means if there is a space in the value, output the split expression, otherwise just output Name.ToString

This way it only tries the split if there is a space in Name.

No space:
image

image

Space:

image

image

So put condition and in then block put type into activity to avoid from this.

Where I’ve used Name you have to use your row(“Name”)

What does “isn’t working” mean?

Your expression should be:

If(row(“Name”).ToString.Contains(" “),row(“Name”).ToString.Split(” "c)(1),row(“Name”).ToString)

I used Name instead of row(“Name”) in my test to simplify it, since I don’t have a datatable to loop through like you are doing.

1 Like

@beatorres2 kindly review above my post I have edited and put a condition for this problem as a solution

Thank you so much! I was just writing it wrong!

1 Like

It’s unnecessary to convert to String then compare to a string. And you don’t need item.

row(“Name”).ToString.Split(" "c).Count = 2

@postwick ok. Happy. Even you get point from my post. :v:t2:

1 Like

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