# Managing Queues in Studio

> 1. In the **Queues** page, create a queue.
2. In Studio, create an automation project that, for example, collects certain figures from an Excel spreadsheet and stores them in a variable.
3. From the **Activities** panel, drag an **Add Queue Item** activity to the **Designer** panel.
4. In the **Properties** panel, in the **QueueName** field, type the name of the queue created at step 1, between quotation marks.
   :::note
   The queue names are not case sensitive. For example, "Test_QuEuE" and “test_queue” are the same.
   :::
5. From the **Priority** list, select **Low**,**Normal** or **High**, depending on the importance of the items that are added by this activity and how fast you want them to be processed.
6. (**Optionally**) In the **Reference** field, enter a string or string variable to act as an identifier for a queue item or a group of them. (The reference can be used to link your transactions to other applications used within an automation project. Additionally, this feature enables you to search for certain transactions, in Orchestrator, according to the provided custom reference.)
   :::note
   References are not compatible with the 2016.2 or lower versions of Orchestrator or Robot.
   :::
7. (**Optionally**) In the **Deadline** field, add a date representing that the queue item may be processed by that date.
8. (**Optionally**) In the **Postpone** field, add a date representing that the queue item may be processed only after that date.
9. Next to the **ItemInformation** field, select the **Browse**![docs image](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-ellipsis_button-f7ebf2a3.png) button. The **ItemInformation** window is displayed, that enables you to add data to each created queue item.

## Adding items to a Queue

1. In the **Queues** page, create a queue.
2. In Studio, create an automation project that, for example, collects certain figures from an Excel spreadsheet and stores them in a variable.
3. From the **Activities** panel, drag an **Add Queue Item** activity to the **Designer** panel.
4. In the **Properties** panel, in the **QueueName** field, type the name of the queue created at step 1, between quotation marks.
   :::note
   The queue names are not case sensitive. For example, "Test_QuEuE" and “test_queue” are the same.
   :::
5. From the **Priority** list, select **Low**,**Normal** or **High**, depending on the importance of the items that are added by this activity and how fast you want them to be processed.
6. (**Optionally**) In the **Reference** field, enter a string or string variable to act as an identifier for a queue item or a group of them. (The reference can be used to link your transactions to other applications used within an automation project. Additionally, this feature enables you to search for certain transactions, in Orchestrator, according to the provided custom reference.)
   :::note
   References are not compatible with the 2016.2 or lower versions of Orchestrator or Robot.
   :::
7. (**Optionally**) In the **Deadline** field, add a date representing that the queue item may be processed by that date.
8. (**Optionally**) In the **Postpone** field, add a date representing that the queue item may be processed only after that date.
9. Next to the **ItemInformation** field, select the **Browse**![docs image](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-ellipsis_button-f7ebf2a3.png) button. The **ItemInformation** window is displayed, that enables you to add data to each created queue item.

Figure 1. ItemInformation window

   ![Screenshot of the ItemInformation window](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-screenshot-of-the-iteminformation-window-226053-9d126f26.webp)

   :::note
   The value of the string arguments added in the **ItemInformation** window cannot contain the following characters: `[` and `" "`
   :::

10. Select **Create Argument**. A new blank argument is created.
11. Change the name of the argument to something more suggestive for your needs.
12. Change the **Type** of the argument to what you need. For example, if you want to store numerical values from transactions, select **Int32**.
13. In the **Value** field, enter the value that you want to add to queue items or a variable that you use to store a specific value.
14. Select **OK**. Your settings are saved.
    :::note
    Place these types of automation projects in a loop. Otherwise, only one item is created and populated in Orchestrator.
    :::

The data added in the **ItemInformation** window in Studio is displayed in the **Item Details** window, under **Specific Data**, in Orchestrator. All items added to queues have the status set to **New**.

Figure 2. Item Details window

![Screenshot of the Item Details window](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-screenshot-of-the-item-details-window-229745-f85e42c9.webp)

## Getting items from a Queue and changing their status

1. In Orchestrator, consider you have a queue populated with items.
2. In Studio, from the **Activities** panel, drag a **Get Transaction Item** activity to the **Designer** panel.
3. In the **Properties** panel, in the **QueueName** field, type the name of the populated queue from Orchestrator, between quotation marks.
   :::note
   The queue names are not case sensitive. For example, "New_QueUe" and “new_queue” are the same.
   :::
4. Create a QueueItem variable. This variable stores the first item from a queue, according to its priority and deadline. When placed in a loop, the Robot iterates through all queue items. After a queue item passes through this activity it is NOT processed, and the status of the item changes to **In Progress**.
5. In the **TransactionItem** field, enter the QueueItem variable created previously.
6. From the **Activities** panel, drag a **Decision** activity under the **Get Transaction Item** activity.
7. Create your automation requirements. For example, add the transaction items to an Excel spreadsheet and send e-mails with this information.
8. In the **Properties** panel, in the **Condition** field, type a condition (for example, the queue item is empty) based on which the status of the item can change.
9. From the **Activities** panel, drag a **Set Transaction Status** activity and connect it to the **False** branch of the **Decision** activity. All transaction items that pass through this activity do not meet the condition added at step 7.
10. In the **Properties** panel, from the **Status** drop-down list, select **Successful**. This status is applied to all queue items that pass through this activity.
11. In the **TransactionItem** field, enter the QueueItem variable used at step 5.
12. (**Optionally**) Select the **Browse**![Browse icon](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-ellipsis_button-f7ebf2a3.png) button next to the **Analytics** field and enter the data that you want to be displayed in the **Item Details** window, in the **Analytics** field.
13. (**Optionally**) Select the **Browse**![Browse icon](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-ellipsis_button-f7ebf2a3.png) button next to the **Output** field and enter the data that you want to be displayed in the **Item Details** window, in the **Output** field.
    :::note
    This information is only displayed if the queue item is processed successfully.
    :::
14. Drag another **Set Transaction Status** activity to the **Designer** panel and connect it to the **True** branch of the **Decision** activity. All queue items that pass through this activity meet the condition added at step 7.
15. In the **Properties** panel, from the **Status** field, select **Failed**. This status is applied to all queue items that pass through this activity.
16. In the **TransactionItem** field, enter the QueueItem variable used at step 5.
17. From the **ErrorType** list, select **Business** or **Application**, depending on the condition you put in the **Decision** activity. For example, an empty queue item could be an application exception, while a transaction value being smaller than a standard value could be a business exception. For more information on this choice, see the [Business Exception vs Application Exception](https://docs.uipath.com/orchestrator/standalone/2023.10/user-guide/business-exception-vs-application-exception#business-exception-vs-application-exception) article.
18. In the **Reason** field, type a string to explain why the exception was triggered. After the project is executed, this information is displayed in the **Item Details** window.
19. Connect both **Set Transaction Status** activities to the **Get Transaction Item** activity. This creates a loop and enables you to iterate through all queue items. A basic automation project should look as in the following screenshot.

Figure 3. Basic automation project

![Screenshot of a basic automation project](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-227396-ec1bd6cb.webp)

A mapping of the properties in the **Set Transaction Status** activity (on the left) and their corresponding fields in the **Item Details** window in Orchestrator.

Figure 4. Set Transaction Status activity

![Screenshot of the Set Transaction Status activity and corresponding fields](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-docs-image-226723-18ee24e0.webp)

To retrieve specific data from a queue item, you can use the `SpecificContent()` function. Write the name of the argument that was used to add information to the queue between quotation marks in brackets.

Figure 5. Expression Editor

![Screenshot of the Expression Editor](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-screenshot-of-the-expression-editor-225762-b387dbfb.webp)

For example, the screenshot above displays the **Value** field of an **Assign** activity. It enables you to retrieve the value attributed to a queue item (displayed in the **Item Details** window, under **Specific Data**, in Orchestrator) and assign it to a string variable, so that you can process it later.

In the screenshot above:

* `transItem` - is a QueueItem variable used to store transaction items.
* `.SpecificContent` - is the function that retrieves information from transaction items.
* `("transactionID")` - is the name of the argument that was added in the **ItemInformation** window to populate the queue items with data. The argument name is also displayed in the **Item Details** window, under **Specific Data**, in Orchestrator.
* `.ToString` - is a function used to convert the ID of the queue, which was initially an integer, to a string.

## Postponing a Transaction Item

1. In Orchestrator, consider you have a queue populated with multiple items.
2. In Studio, consider you already have a **Get Transaction Item** activity that iterates through all queue items.
3. From the **Activities** panel, drag a **Decision** activity to the workflow. The activity enables you to make a business decision, based on which to postpone some queue items. For example, if the value of a bill is grater than 3000$, you might want to postpone its payment.
4. From the **Activities** panel, drag a **Postpone Transaction Item** activity to the **True** branch of the **Decision**. This means that all queue items that meet the condition placed in the **Decision** activity are postponed according to your configurations.
5. In the **TransactionItem** field, enter the QueueItem variable used in the **Get Transaction** activity.
6. In the **Postpone** field, add the date after which this item can be processed.
7. In the **Deadline** field, add the date before which this item has to be processed.

The **Deadline** and **Postpone** properties add a new priority to queue items. For example, a queue item which is due today at 7 pm and has a **Medium** priority is processed first, before another item that has no due date and a **High** priority.

   :::note
   Modifying the deadline of a queue item or postponing it changes its status to new.
   :::

## Adding a custom progress

1. In Orchestrator, consider you have a queue populated with a lot of items (millions) with the **In Progress** status.
2. In Studio, consider you already have a **Get Transaction Item** activity that iterates through all queue items and uses a QueueItem variable.
3. From the **Activities** panel, drag a **Set Transaction Progress** activity to the **Designer** panel.
4. In the **TransactionItem** property of the activity, enter the QueueItem variable.
5. In the **Progress** property, add a custom string to describe the progress reached here, such as "BeforeFirstDecision". That lets you know that the item has been retrieved from the Orchestrator database. If your automation project crashes at this point during the execution, one item has this status, and it is displayed in the **Progress** column.
   :::note
   Custom progress statuses are only displayed while an item has the **InProgress** status.
   :::

The remainder of the automation project can be set as explained above.

For example, the following workflow example sets each item status to **Successful** or **Failed** automatically, depending on how you design the **Transaction Body** sequence:

* **Do nothing**,**Break**, or **Continue**- results as **Successful**
* **Throw Exception** - results as **Failed (Application error)**
* **Throw BusinessRuleException** - results as **Failed (business error)**
* **Set Transaction Status** - results as the status you set
* **Postpone Transaction Item** - results as **New**
* **Should stop** - if you stop the workflow from Orchestrator, the workflow exists the loop after the current transaction completes. The workflow repeats for every queue item automatically, and sets the corresponding transaction status. In case of **Break** or if the queue is empty, the workflow exists the loop.

Figure 6. Automation project

  ![Screenshot of the automation project](https://dev-assets.cms.uipath.com/assets/images/orchestrator/orchestrator-screenshot-of-the-automation-project-225857-0d09da59.webp)

[Download](https://documentationexamplerepo.blob.core.windows.net/examples/Orchestrator/ProcessQueueItem.zip) the archived workflow and use it as a reference.
