Why this Exception is coming " index and length must refer to a location within the string "

Why this Exception is coming " index and length must refer to a location within the string ".

In my case its working fine in Development but not showing


error on Production. Please help me to solution .

Hey @Ajinya_jorwekar
There must be an error in the expression used in ‘Type Into’ activity.
Possibly in the Substring(). Can you please share the expression?

Also Try using inDtAdvicePdfData.Rows(0)(0).ToString.Substring()
Make sure the column index is used instead of the column name

1 Like

@Ajinya_jorwekar

The exception "index and length must refer to a location within the string" in UiPath is thrown when you try to create a substring of a string that is outside of the bounds of the string. This exception can occur in UiPath for a number of reasons, including:

  • You are trying to create a substring that starts at an index that is greater than the length of the string.
  • You are trying to create a substring that has a length that is greater than the length of the string.
  • The string that you are trying to create a substring from is empty.

To avoid this exception, you should make sure that the index and length parameters of the Substring() activity are within the bounds of the string. You can also use the IsEmpty() activity to check if the string is empty before you try to create a substring.

HI,

For now, can you check and share content of inDtAdvicePdfData.Rows(0)("RATE").ToString?
Probably it’s not same what you expect.

Regards,

Hi @Ajinya_jorwekar

Not recommended to use the Substring function in Type into activity.

Do the Substrings function and Store the data in a variable and pass the variable in the type into activity and try.

Hope it helps!!