Issue in add item to array

Hello Team,
Currently we are performing the following activities to add item to array

1)Read Google sheet and add to data table dt_Sheet

2)Use for each row for data table and perform manipulations for one of the column whose output is stored in String Format (str_Validity)

3)Trying to add each of the str_Validity string data to an array in below format

strItem_List=strItem_List.Append(row.Item(str_Validity).ToString).ToArray

But this approach is not working

Your guidance is appreciated!!

Hi @anmita

Better to use the Append items to Collection activity to append the new items to array.
image

Hope it helps!!

Hi @anmita

Could you please try the following:

strItem_List = New List(Of String)()

For Each row As DataRow In dt_Sheet.Rows
strItem_List.Add(row.Item(str_Validity).ToString)
Next

strItem_Array = strItem_List.ToArray()

Hope this helps,
Best Regards.

Hi @anmita ,

Create a list of strings and add items to it.
You can use Invoke Method activity inside the for loop to achieve the same.

Below is the screenshot for your reference.

Here is the code for the same.
Try_me.xaml (8.3 KB)

Regards,
Ashutosh Gupta

hello @arjunshenoy

Did you invoke some script for this part?

For Each row As DataRow In dt_Sheet.Rows
strItem_List.Add(row.Item(str_Validity).ToString)
Next

@anmita

You can use the ‘Invoke Code’ activity for this.

Best Regards.

Its not working @arjunshenoy any other approach we could try

Have declared the arguments also but still its giving exception

Exception has been thrown by Target of an Invocation

is str_Validity a variable and is reflecting the column name?

otherwise change to
strItem_List=strItem_List.Append(row.Item(COLNAME_OR_INDEX).ToString).ToArray

Hii @ppr

yes its a variable that we have

That we are trying to add to array

@anmita

Try using Assign activity to add Items to array. This will surely work for you.

Str_Array = Str_Array.Concat({row.Item(str_Validity).ToString}).ToArray

Thanks

i am not sure if the feedback was got properly

when the value which is to add has to be retrieved from the datarow
then use the column name or index for accessing it

lets assume column name is “VALIDATION_RESULT”
strItem_List=strItem_List.Append(row.Item("VALIDATION_RESULT").ToString).ToArray

Hii @pratik.pandya , @ppr

Actually this is the process

1)Read Google sheet and add to data table dt_Sheet

2)Use for each row for data table and perform manipulations for one of the column whose output is stored in String Format (str_Validity)

3)Trying to add each of the str_Validity string data to an array one by one

str_Validity is not a column in data table

when str_Validity is the string variable and represents the edited value, then we will not use it like a column name

strItem_List=strItem_List.Append(str_Validity).ToArray

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