How to resolve the issue "Index out of range exception"

Dear all,

Good day.

I have a project to issue billing when the user has create for delivery order in the system.

Usually the user will submit a request (an excel file) - attached input template

in the delivery order column, user will fill in the number as an array (all together separated “,”)

then i will assign each split string as an variable.

i face an issue whereby the number of DO is not fixed, sometimes is 3 , sometimes is 4.

So if the user only input three DO number and i have assign until 5 set, then it will thrown an error (Index out of range exception).

Kindly advise how can i assign the DO as variable without any error prompt.
Main.xaml (15.2 KB) input template (04112020).xlsx (11.0 KB)
Thank you.

Hi,

Usually, we can use For Each activity to iterate each number without exception as the following image.
If users input number of DO less than what we expect, we might need to handle for it.

Regards,

@Yoichi Thanks for your reply.

However, what i need is after i assign each OD as the variable like ODNo1 and so forth then i will need to input those number into system to create billing.

So now, i was not able to predict or confirm the number of DO.

You are suggesting to use “For each” activity, but how can i do it actually?

The write cell activity is actually a trial activity which will not be use.

Hi Irene,

As @Yoichi mentioned you can use for each loop to iterate through all the DO after splitting it.
The steps you want to perform with each individual DO, you need to develop it as a new workflow and invoke it inside the loop and pass the Item/DO as argument. else develop the whole code inside the for each in the same main workflow.

Hope this helps.