i have 3 for each loop i need to take the first value from first loop then go to the second loop take first value then go to third loop take first value , then return to get the second value from each loop , how can i do this ??
I’m not sure I totally understand what you are trying to do, but here is a quick process I made that loops through 3 arrays and adds each item to a data table as it goes.
Is this kind of like what you are trying to do?
Instead of using 3 loop use 1 loop.
If the total number of values in 3 collection is same then
first create int variable->arrayLength=array.length
2nd) create 2nd variable int Counter->0 initialize it
3rd) use while loop and with the condition Counter<=arrayLength
4rd) inside loop create three variable
FirstCollectionVariable1=firstCollectionArrayname(counter)
secondCollectionVariable1=2ndCollectionArrayname(counter)
thirdCollectionVariable1=3rdCollectionArrayname(counter)
Now add them into datatable through Add data Row activity
5th)increment the counter variable. Counter=Counter+1
orders":[{"order":"123"},{"order":"456"},{"order":"789"}]]
numbers":[{"num":"7897"},{"num":"4565"},{"num":"3435"}]]
data like this collections with elements
Here it is, @rpa13 . I have not tried @ghazanfar 's solution before, but I will do that now. That is a more elegant solution, though I think mine will work similarly (though possibly more slowly). Main.xaml (10.5 KB)
@Joe.Matuch
but my data is jobject
like this
orders":[{“order”:“123”},{“order”:“456”},{“order”:“789”}]]
numbers":[{“num”:“7897”},{“num”:“4565”},{“num”:“3435”}]]
@ghazanfar , I think that solution will only produce entries that have all the first entries, all the second entries, all the third entries, etc. My understanding is that @rpa13 wanted the first entry in the array with all the different combinations of entries from the other arrays.
I will take a look at changing my solution to work with the data the way you have it formatted, @rpa13 . So your data is a dictionary with strings as both the keys and values?
This is array not dictionary look there are no keys in it.
How we split the values to get required value like this way…
orders":[{“order”:“123”},{“order”:“456”},{“order”:“789”}]]
assign FirstArrayValue1=orders(index)
assign FirstArrayValue1=split(FirstArrayValue1,“:”)(1)
it will return 123
test.xaml (15.1 KB)
here is and my data i take in jobject by api call
example of data i get in json object like this
"material":[{"sku":"0345"},{"sku":"0692"},{"sku":"0630"}]
So lets assume yourJson(“material”) Value is a JArray with the JObjects: {“sku”:“0345”},{“sku”:“0692”},{“sku”:“0630”}
And any other array will do have the same length
Parse the arrays with e.g.
arrJMaterial = JArray.Parse(yourJson(“material”).toString) or any other methods
Prepare a datatable with the structure you do need - Var dt
then construct the datarows - 1 row many cols
For each TypeArgument is Int32
x = Enumerable.Range(0,arrJMaterial.Count)
So Just complete it for the other cols
Write date afterwards and not within loop with write range using the datatable