Dividing the data in the string variable

Hi Team,

Input:
items=‘H44942LZ’,‘H44952LJ’,‘H44952LA’,‘H43222LB’,‘H44952LB’,‘H44952LC’,‘H44952LD’,‘H44952LJ’,‘H44942LZ’,‘H44952LA’,‘H44952LA’,‘H44952LC’,‘H44952LC’,‘H44952LC’,‘H44952LC’,‘H44952LJ’,‘H44942LZ’,‘H44952LC’,‘H44952LC’,‘H43222LB’,‘H43222LB’,‘H44952LA’,‘H44952LB’,‘H44952LD’,‘H44952LA’

items is a string variable

for example if i have 500 items in Items Variable i need to divide it into 50 items and enter 50 items in the textbox in application and download the report and enter 2nd 50 items in the same text box in application and download the second report in same way untill 500 items completed

each set should be 50 items

Please provide solution

Thanks
Likitha

Hi @vinjam_likitha,

There may be different solutions, but my suggestion would be to use the mod operator within an if statement inside a for loop. Every 50 iterations, the can enter the if block to download the report and reset the page to its logged-in state. I hope this gives you an idea.

Regards,
MY

we can split the string e.g. when like above
arrPart = item.Split(","c).Select(Function (x) x.Trim({"'"c})).toArray

First Segment
arrSplit = arrSplits .Skip(0*50).Take(50).toArray

Second Split:
arrSplit = arrSplits .Skip(1*50).Take(50).toArray


With variables and some other techniques, we can fully dynamize it

Hi @vinjam_likitha

Can you try this.

  1. Split the items string into an array using the comma (, ) separator:
    itemsArray = items.Split(","c)
  2. Calculate the total number of sets required:
    setsCount = Math.Ceiling(itemsArray.Length / 50)
  3. Use a For Each activity to loop through each set of items:
  • Set the TypeArgument property of the For Each activity to String
  • Set the Values property of the For Each activity to the following expression:

Enumerable.Range(0, setsCount).ToArray()

  1. Inside the loop, use a Assign activity to get the current set of items:
  2. Use a Type Into activity to enter the current set of items in the text box in the application.
  3. Inside the loop, use a Click activity to download the report.
  4. Inside the loop, use a Delay activity to wait for the report to download.
  5. Inside the loop, repeat for the next set of items.

I hope it helps you.

1 Like

In For each loop in assign activity what should i add?

Firstly , Set the To property to a new variable named “currentSet” of type array of string and then

Set the Value property to the expression “itemsArray.Skip(index * 50).Take(50).ToArray()”, where “index” is the loop variable of the For Each activity.