# Structure of Loops - 2.0 with Queues

Hi,

I posted a question before which you can find at this link: https://forum.uipath.com/t/structure-of-loops/301007

I need to insert data FROM an Excel onto a website. In one part I need to fill ALL the data of a particular row if the Account = 0kg. If not I ONLY need to fill in the data of 2 particular columns(Column1 and Column2) of the NEXT row and check again if Account = 0kg. Below are the steps:

1. Type Row(1) of DataTable(From excel to Website)
2. Check if Account = 0kg: (On website(UI Element))
3. If YES: Click â€śCloseâ€ť â†’ Type Into Row(2) of DataTable(From excel to Website)
4. If NO: Type into Row(2)(â€śColumn 1â€ť) AND Type into Row(2)(â€śColumn 2â€ť)
5. Check if Account = 0kg:
6. If YES: Click â€śCloseâ€ť â†’ Type Into Row(3) of DataTable(From excel to Website)
7. If N0: Type into Row(3)(â€śColumn 1â€ť) AND Type into Row(3)(â€śColumn 2â€ť)

Can someone please tell me how can I do this?
Should I use a For loop, a While loop, a While Do Loop, â€¦

I used a for loop inside a for loop but I think everything is going berserk!

How do I update the Row number? For ex: Row(1), Row(2), Row(3)â€¦
How can we update a row with a counter?â€śâ€ť

## And @ [NIVED_NAMBIAR] helped me with the structure in this xaml file: Main.xaml (14.0 KB)

I tried it and it worked. But now I wanted to know if we could do it using Queues?
What can we change in the xaml file to make it work with queues?
For example: when working with Excel, it is easy to find Row(3)(â€śColumn 1â€ť) and Row(3)(â€śColumn 2â€ť). But how to do it with Queues?

Thanks for help!

Note: I already sent my data to Orchestrator!

As youâ€™ve already sent data to orchestrator, now instead of reading data from excel, use get transaction item activity and store data in queue item type variable(say TSitem). If you can see your data in queue item specific content, then you can use assign activity and store the value TSitem.SpecificContent(â€śItemNameAsInYourQueueItemâ€ť) to the variable data1, similar actions for data2. Now keep the remaning part of your workflow as it is.

Hope you understood. If you can share screenshot of your queue item, I can give more clear code.

1 Like

How do I convert these into queues?
Also, I have a variable Count which gets updated in the while loop. Will it still work in the queues?

Thanks!

You should use TSitem.SpecificContent(â€śItemNameAsInYourQueueItemâ€ť).ToString only in the places where you have DataTable.Rows(count)(â€śColumn1â€ť).ToString and DataTable.Rows(count)(â€śColumn2â€ť).ToString. You donâ€™t need to use count variable any more. Also instead of the conditon <count<dt1.Rows.Count> use . Itâ€™s also a good idea to update your transaction item status to successful or failed, using set transaction status activity, after your job is done.

Go through the courses â€śVariables, Data Types and Control Flowâ€ť, â€śData Manipulationâ€ť and â€śRPA developer advanced learning planâ€ť in UiPath academy, if you want to understand how to work with variables, data tables and queues.

Well, it is not going to be the same thing if I donâ€™t use count.

There are places where I need to put the data of the Next Row of column 1 and 2 only and places where I need to put data of the enitre Row.

If I cannot use count, I cannot specify the SpecificContent each time manually.

The Set transaction thing is okay. But I need to use a Business Exception as the next row depends on the previous row, so if there is any problem, the robot should stop.

Then you should upload all the row data to transaction item. Now instead of storing specific content in data 1 and data 2 variables, store all the specific content one by one into an array or list(say currentArray). As soon as your job is done with this transaction , then store this currentArray into another array variable(say PreviousArray). For this first time, your PreviousArray can contain empty values. Now you have two arrays representing previousRow and currentRow. You can make use of these arrays to build your workflow. Please note that all your transaction items should be processed by single robot and if you like to set priority, then set same priority for every transaction item.

does it help?

Hi @Yudhisteer_Chintaram1
sorry for delayed response

let me know if it works for you
Queue_System.xaml (24.5 KB)

Regards,
Nived N
Happy Automation

1 Like

Thanks @NIVED_NAMBIAR ,

I am a few questions,

1. Does this process below represent this: Row(2)(â€śColumn 1â€ť) AND Type into Row(2)(â€śColumn 2â€ť)

In the earlier file, the process was as such:

I am asking because we donâ€™t use â€ścountâ€ť in the expression â€śtransaction_item.SpecificContent(â€śColumn 1â€ť).ToStringâ€ť.

Or, when we go back to activity â€śGet Transactionâ€ť it automatically fetch the next row?

Thanks!

yes both represent same thing as u said

1 Like

I am testing it. I think it should work fine.

One more help @NIVED_NAMBIAR ,

in the structure before we used a â€śWHILEâ€ť loop, and now we are using a Flowchart(for the Queues).
Can we change the structure before into a Flowchart type as well?

Thanks!

Hi @Yudhisteer_Chintaram1
yes it seems, need to tryout that

Let me try that @Yudhisteer_Chintaram1

1 Like

Hi @NIVED_NAMBIAR
Any luck?

Just have a look at this workflow for datatable
Queue_System.xaml (23.2 KB)

Regards,
Nived N
Happy Automation

1 Like

Thank a lot again!!!

I have a Type Into activity with the following expression:

dt1(count)(â€ścolumn1â€ť).ToString

And in your structure you assigned data_1 to:

dt1.Rows(count)(â€ścolumn1â€ť).ToString

I wanted to know what is the difference between these two expressions?Can they be used interchangeably?>

Thanks!

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