Index was outside the bounds of array-URGENT

Hi @kumar.varun2 @GreenTea
This is URGENT !!!
while debugging the code i encountered this issue.

@mitul_choudhary

Send the code written inside the assign activity

To : drInvoiceMain.Item(item.ColumnName)
Value : Split(in_strPdfLines(strLineIndex+ Int32.Parse(in_dtblTemplate.Rows(2).Item(item).ToString)).Trim,in_dtblTemplate.Rows(4).Item(item).ToString)(Int32.Parse(in_dtblTemplate.Rows(5).Item(item).ToString)).Trim

Screenshot:-


@mitul_choudhary

What is the Data Type of in_strPdfLines?
Can you send one row of in_dtblTemplate?
What is the value of strLineIndex?
What is the value of item?

What is the Data Type of in_strPdfLines ? String

What is the value of strLineIndex ? 27
What is the value of item ? [Return Month And Year (MM-YYYY)]

Can you send one row of in_dtblTemplate ?
[Section,Location / Unit / Sub Org Code,Location / Unit / Sub Org GSTIN,Return Month And Year (MM-YYYY),Transaction Type,Transaction Subtype,Invoice Type,Line Item ID,Bill / Invoice No,Bill / Invoice Date,Bill / Invoice Value,Original Bill / Invoice / Bill of Entry Number,Original Bill / Invoice / Bill of Entry Date,Supplier GSTIN / UIN,Supplier GST Registration Status,Place of Supply (POS),Indicate if Supply Attracts Reverse Charge,GST Supply Category,Eligibility of ITC,Reversal under Rule 42/43,Taxable Value,GST Rate,IGST Amount,CGST Amount,SGST / UT GST Amount,GST Compensation Cess Amount,IGST - ITC Available,CGST - ITC Available,SGST / UT GST - ITC Available,GST Compensation Cess - ITC Available,Entity-1,Entity-2

Screenshot for same from which i got one roow in_dtblTemplate:-

@kumar.varun2 Please help…!!!

You should chop this into individual variables and then debug.

@mitul_choudhary

What is required output from the above Split code?

just trying to extract information from invoices & paste it into excel.

What is the value of in_dtblTemplate.Rows(5).Item(item).ToString?

value of in_dtblTemplate.Rows(5)

[Section,Location / Unit / Sub Org Code,Location / Unit / Sub Org GSTIN,Return Month And Year (MM-YYYY),Transaction Type,Transaction Subtype,Invoice Type,Line Item ID,Bill / Invoice No,Bill / Invoice Date,Bill / Invoice Value,Original Bill / Invoice / Bill of Entry Number,Original Bill / Invoice / Bill of Entry Date,Supplier GSTIN / UIN,Supplier GST Registration Status,Place of Supply (POS),Indicate if Supply Attracts Reverse Charge,GST Supply Category,Eligibility of ITC,Reversal under Rule 42/43,Taxable Value,GST Rate,IGST Amount,CGST Amount,SGST / UT GST Amount,GST Compensation Cess Amount,IGST - ITC Available,CGST - ITC Available,SGST / UT GST - ITC Available,GST Compensation Cess - ITC Available,Entity-1,Entity-2
Word,Name:,GSTN/UIN,Invoice Date:,Invoice No:,Invoice Date:,Total,GSTIN of Supplier:,Place of Supply:,PNR No
WordMatch,Start,Start,Start,Start,Start,Start,Start,Start,Start
Position,0,0,0,0,0,0,0,0,0
IsSplit,Y,Y,Y,Y,Y,Y,Y,Y,Y
SplitWord,:,:,/,:,:, ,:,/,:
SplitPosition,1,1,1,1,1,Last,1,1,1
ReplaceWith,
IsMultiline,
MultilineEndWord,
FindPosition,
MultilineEndPos,
IsDecimal,Y,
RemoveWord,
DefaultValue,
]

Screen shot for same:-

Value of Items:-
[Return Month And Year (MM-YYYY)]

Screenshot for same:-

@mitul_choudhary

How many rows and columns are there in in_dtblTemplate ?

Hi @mitul_choudhary,

This issue will normally occur if you refer to an item in an array that doesn’t exist. Check the row/column or substring that you are referring to exists

How can i confirm on that …?
@kumar.varun2 .pls help with the process…?

@mitul_choudhary

While debugging, in the immediate panel run the following commands

to check the number of rows - in_dtblTemplate.Rows.Count
to check the number of cols - in_dtblTemplate.Columns.Count

@kumar.varun2 now pls help…!!!

@mitul_choudhary

Can you share the files?
Also, in the immediate panel check the value of in_strPdfLines(27)

@mitul_choudhary

The syntax of Split function is like this

Split(stringToBeSplit, Delimiter)

When the Split function is applied it gives an array of string with split words.

e.g., Split("gone:with:the:wind", ":") would give an array like {"gone", "with", "the", "wind"}

So if from this array I only want element at position 1 then I would use

Split("gone:with:the:wind", ":")(1)

and this would give "with"

In your case stringToBeSplit = "Invoice Date:"
and the Delimiter = ":"
and the element at position 1 is required

Split("Invoice Date:", ":")(1) it would give error as the array contain only one element {"Invoice Date"}.There is no element at position 1 but only at position 0

1 Like

I literally told you yesterday to use variables in your statement above instead of the way you have it. You cannot debug the code like this…
once you have your variables set, your locals pane will tell you which variables are faulty/null/incorrect.