# Implementing a complex process

> An advanced process may combine multiple automations, human approvals, and AI agents, orchestrated with decision logic and monitoring for scale and governance. This section introduces you to an advanced flow so you can explore more complex scenarios right away.

## Overview

An advanced process may combine multiple automations, human approvals, and AI agents, orchestrated with decision logic and monitoring for scale and governance. This section introduces you to an advanced flow so you can explore more complex scenarios right away.

In this example, the fictional company InsurePath identified an invoice processing workflow with UiPath® Process Mining. They use UiPath IXP and Document Understanding to process incoming invoices and extract invoice data. After extraction, the finance and accounting teams still process most invoices manually, including resolving vendor disputes.

The process owner, together with process implementers and administrators, decided to address the invoice processing problem with UiPath Maestro™ and platform capabilities.

## Process

Build a working invoice processing process to demonstrate how Maestro coordinates work between robots, agents, and humans.

This is the BPMN diagram for the process we will build.

![BPMN diagram of the invoice processing process showing all tasks, gateways, and flow paths](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-process-diagram-599989-7f31b59a.webp)

## Prerequisites

We need to configure the dependent resources for this scenario.

**Data Fabric: APInvoice entity**

Use the Record Created event for the APInvoice entity to trigger the start of our process.

1. Navigate to Data Fabric.
2. In the **Import/Export** dropdown menu, select **Import Schema**.
3. Import the [Schema(APInvoice).json](https://documentationexamplerepo.blob.core.windows.net/examples/Maestro/Schema%28APInvoice%29.json) file.

   ![Import schema dialog in Data Fabric](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-import-schema-598500-e74b6e51.webp)

4. Check the **Import** checkbox corresponding to the **APInvoice** entity.
5. Select **Import**.

   ![import button data fabric](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-import-button-data-fabric-598519-3c735391.webp)

**Orchestrator: Shared Folder**

Use a shared folder in Orchestrator to organize the How To resources.

Navigate to Orchestrator and create a **Shared/How To** folder. Eead more about [Managing folders](https://docs.uipath.com/orchestrator/automation-cloud/latest/user-guide/managing-folders#managing-folders) in Orchestrator.

**Automation: Invoice to PO matching**

Use a mock automation to simulate invoice-to-purchase-order two-way matching. The process takes an input argument for **Invoice Number** and sets the **ResolutionRequired** output variable. If the invoice number starts with `1`, the value is **Yes**. Otherwise, it is **No**.

1. Navigate to Studio Web and select **Import** from the **Create new** drop-down list. Use this [file](https://documentationexamplerepo.blob.core.windows.net/examples/Maestro/Invoice%20To%20PO%20Matching.uip) to import.

   ![Create new dropdown with Import option in Studio Web](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-create-new-598533-2769133e.webp)

2. Open the project in UiPath Studio Web and publish it to Orchestrator Tenant Processes Feed.
3. Navigate to Orchestrator and go to the **Shared/How To** folder.
4. Open the **Automations** tab, choose **Processes**, and select **Add process**.
5. Select **Invoice.To.PO.Matching** in the Package Source Name field and select **Next**.
6. In the **Package Requirements** section, select **Next** .
7. Provide **Invoice to PO matching** for Display Name and select **Create**. Check the Studio Web Publishing a project page for additional details on publishing and deploying projects.

**Automation: Post invoice to SAP**

Use a mock automation to simulate posting the invoice to SAP. The process takes an input argument for **Purchase Order Number** and has no outputs. If the purchase order number equals `fail`, the process throws a runtime exception that you can repair in instance management.

1. Navigate to Studio Web, and select **Import** from the**Create New** drop-down list. Use this [file](https://documentationexamplerepo.blob.core.windows.net/examples/Maestro/Post%20Invoice%20to%20SAP.uip) to import.
2. Open the project in Studio Web and publish it to Orchestrator Tenant Processes Feed.
3. Navigate to Orchestrator, go to the **Shared/How To** folder.
4. Select the **Automations** tab, choose **Processes**, and select **Add process**.
5. Select **Post.Invoice.To.SAP** in the **Package Source Name** field, and select **Next**.
6. In the **Package Requirements** section, select **Next** .
7. Provide **Post invoice to SAP** for Display Name and select **Create**. Check the Studio Web Publishing a project page for additional details on publishing and deploying projects.

**Agent: Resolve discrepancies agent**

1. Navigate to Agents and select **Build your agent now**.
2. Enter the following details: **Name**: Resolve Discrepancies Agent **Description**: Resolve discrepancies agent **System prompt**: You are an expert in Resolving Invoice Discrepancies

**User prompt**: If the \{\{InvNum\}\} start with 11 you will Resolve the invoice. Else you will reject the invoice and give the \{\{Reason\}\} for rejection as `Needs human review since the PO Number doesn't match the Invoice`.

When you reject the invoice set \{\{Decision\}\} to `Rejected` and if you approve the invoice set \{\{Decision\}\} to `Resolved`.

1. Select **Arguments** and enter the following using the **Editor** option:

   **Inputs**

      ```
      {
      "type": "object",
      "properties": {
         "InvNum": {
            "type": "string"
         },
         "PONum": {
            "type": "string"
         }
      },
      "required": [
         "InvNum"
      ]
      }
      ```

   **Outputs**

      ```
      {
      "type": "object",
      "properties": {
         "Decision": {
            "type": "string"
         },
         "Reason": {
            "type": "string"
         }
      },
      "required": []
      }
      ```

2. Publish to Orchestrator Tenant Process Feed.

**Action app: Invoice Approval Action App**

1. Navigate to Studio Web, and select **Import** from the **Create New** drop-down list. Use this [file](https://documentationexamplerepo.blob.core.windows.net/examples/Maestro/Invoice%20Approval%20Action%20App.uip) to import.
2. Open the project in Studio Web and publish to Orchestrator Tenant Processes Feed.

   You may need to navigate to `MainForm_MainForm_load.xaml` and update entities. From **Data manager**, go to **Entities**, and select **Update entities** before you can publish.

   ![Update entities option in the Data Manager](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-update-entities-598624-cc526fce.webp)

3. Navigate to **Orchestrator**, go to the **Shared/How to** folder, open the **Automations** tab, select **Apps** and choose **Deploy app**.

## Model an agentic process

:::note
Agentic process project configuration is currently tenant-bound. Make sure that you remain in the same tenant between editing sessions.
:::

Start by modeling the end-to-end process, then configure the components.

Create an agentic process as a new type of Studio project.

1. Navigate to your Automation Cloud™ tenant.
2. On the rail on the left side, from the list of products, select **Maestro**.
3. On the **Maestro** landing page, select **Start modeling**. Your new agentic process opens.

   You can also start by creating a new **Agentic Process** in **[Studio Web](https://docs.uipath.com/studio-web/automation-cloud/latest/user-guide/creating-an-agentic-project).**

   ![agentic orchestration type process](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-agentic-orchestration-type-process-597029-1e7e8552.webp)

4. Open the context menu to rename the project to **\{your initials\} Invoice Process**, and the process to **Invoice Process**. Your agentic process is, by default, part of a solution. Read about solutions in the [Studio Web user guide](https://docs.uipath.com/studio-web/automation-cloud/latest/user-guide/about-solutions).

   ![rename simple process](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-rename-simple-process-597034-6c904375.webp)

5. Select the start element and Enter **Invoice received** in the name field.
6. Select **Add: Text annotation** from the toolbox. Enter **Data Fabric trigger** in the annotation.

   ![add text annotation](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-text-annotation-597038-7c1265f7.webp)

7. Select the start element and choose **Add Task** from the toolbox and Enter **Invoice to PO matching** for the task name.

   ![Invoice to PO matching task added to the canvas from the start element](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-task-598814-2a270b7f.webp)

8. Select the **Invoice to PO matching** task and choose **Add: Text annotation** from the toolbox and Enter **Automation** to indicate we want this to be an automation task.

**Invoice to PO matching outgoing paths**

Configure two outgoing paths for the gateway of which only one will be followed based on the outcome from the Invoice to PO matching automation.

1. Select the **Invoice to PO matching** task and choose **Add: Exclusive gateway** from the toolbox and Enter **Is resolution required?** for the name.

   ![add exclusive gateway](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-exclusive-gateway-598818-5e3c5f4d.webp)

2. Select the gateway and choose **Add: Task** from the toolbox and Enter **Invoice approval** for the name. Add **Action Center Action app** as an annotation to indicate we want this to be a HITL task.
3. Select the line just created between the gateway and task and press the **Open properties panel** button in the upper right-side of the designer to change the name to **No**.

   ![open properties panel](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-open-properties-panel-598822-211178e6.webp)

4. Select the gateway again and choose **Add: Task** from the toolbox and Enter **Resolve discrepancies** for the name. Drag and position the task under the gateway. Add **Agent** as an annotation to indicate this will be an agent task.
5. Select the line just created between the gateway and task and open the properties panel to change the name to **Yes**.

**Invoice approval outgoing paths**

Configure two outgoing paths for the gateway of which only one will be followed based on the outcome from the Invoice approval task done by the human.

1. Select the **Invoice approval** task and add another **Exclusive gateway**.
2. Select the gateway, choose **Add: Task** from the toolbox, and Enter **Post invoice to SAP** for the name. Add **Automation** as an annotation to indicate that you want this to be an automation task.
3. Select the line just created between the gateway and task and open the properties panel to change the name to **Approve**.
4. Select the gateway again, choose **Add: Task** from the toolbox and Enter **Notify vendor** for the name. Drag and position the task under the gateway. Add **Integration Service Outlook connector** as an annotation to indicate this will be an API call indicated as a Send task.
5. Select the line just created between the gateway and task and open the properties panel to change the name to **Reject**.

**Resolve discrepancies outgoing paths**

Configure two outgoing paths for the gateway. Only one will be followed based on the outcome from the **Resolve discrepancies** task done by the human.

1. Select the **Resolve discrepancies** task and add another **Exclusive gateway**.
2. Select the gateway and choose the **Connect** arrow from the toolbox.

   ![Connect arrow selected from the gateway toolbox](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-connect-598841-c3b43088.webp)

3. Select the **Notify vendor** task to draw a line from the gateway to task.

   ![Connection drawn from the Resolve discrepancies gateway to the Notify vendor task](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-connection-task-598845-44afa059.webp)

4. Select the line just created between the gateway and task and open the properties panel to change the name to **Rejected**.
5. Use the Connect tool again to draw a line from the gateway to the **Invoice approval** task.
6. Select the line just created between the gateway and task and open the properties panel to change the name to **Resolved**.

**Resolve discrepancies error boundary event**

If the agent cannot resolve the discrepancy, it will return a business error, routing the task back to a human for further input. Model this by adding an Error boundary event to the task.

1. Select the **Intermediate event** in the full toolbox on the left-hand side and drag-n-drop it to the **Resolve discrepancies** task.

   ![Intermediate event dragged onto the Resolve discrepancies task boundary](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-intermediate-event-598853-83b96d20.webp)

   ![resolve discrepancies intermediate event](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-resolve-discrepancies-intermediate-event-598849-ceeccd03.webp)

2. Select the **Intermediate event** and choose **Change element** from the toolbox and select **Error boundary event**.

   ![Change element panel with Intermediate event tooltip and selection](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-docs-image-598858-85e75189.webp)

3. Select the **Error boundary event**, choose **Add: Task** from the toolbox, and Enter **Resolve discrepancies** for the task name. Add **Action Center Action app** as an annotation to indicate we want this to be a human-in-the-loop task.
4. Select the new **Resolve discrepancies** task. Use the Connect tool again to draw a line from the this new task to the agent gateway.

**End events**

It is a best practice to create an explicit end to your process. It's important to quickly know which path your process followed so you can create an explicit end for each one.

1. Select the **Post invoice to SAP** task, choose **Add**: **End event**, and Enter **Invoice processed** for the name.
2. Select the **Notify vendor** task, choose **Add**: **End event**, and Enter **Invoice rejected** for the name.`

Congratulations! You’ve created your first BPMN end-to-end business process. It's time to add some UiPath capabilities to the process.

## Implement an agentic process

**Message start event**

1. Select the start element, choose **Change element** from the toolbox, and select **Message start event**.

   ![message start event](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-message-start-event-599202-9542202a.webp)

2. Open the properties panel and in the **Implementation** section configure the following:
   * **Action**: Wait for connector event.
   * **Connector**: Data Fabric
   * **Data Fabric connection**: Data Fabric.

     :::note
     Choose **Connect to Data Fabric** to create a connection you don’t have one already.
     :::

   * **Trigger**: Record Created.
   * **Object**: APInvoice.

   :::note
   All outputs will be automatically available as variables in the process configuration.
   :::

If you are in a shared environment, you can change the Trigger to **Record Updated** and configure the filter to set **CreatedBy E-mail** equal to your email.

   ![Filter builder configured for the Data Fabric trigger](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-filter-builder-599206-f2d44a61.webp)

**Invoice to PO matching automation**

1. Select the **Invoice to PO matching** task, choose **Change element** from the toolbox. and select **Service task**.
2. Open the properties panel and in the **Implementation**section configure the following:
   * **Action**: Start and wait for RPA workflow.
   * **Automation**: Invoice to PO matching.
3. Configure the inputs by mapping the output from **Invoice received** message start event as inputs to the automation. Use the Variable search dialog to find the variables.
   * **InvNum**: Invoice received &gt; response &gt; Invoice number.

   ![InvNum input mapped to Invoice number in the Properties panel](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-invoice-number-599210-9faa36a2.webp)
   * **PoNum**: Invoice received &gt; response &gt; PO number

   ![PO number field mapping in the Properties panel](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-po-number-599214-c5a2d694.webp)

**The Is resolution required? gateway**

1. Select the **Is resolution required?** gateway, expand the **Conditions** to enter the condition for the **No** and **Yes** paths, and use the **Expression editor** to enter the conditions.

   ![Conditions section with expression editor open](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-conditions-expression-editor-599218-3acd7f42.webp)

2. Use **Insert variable** to find and insert **Invoice to PO matching** output variable **ResolutionRequired**, set the value to “No”, and select **Save**.

   ![ResolutionRequired variable mapped to No in the expression editor](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-resolution-required-599222-eda10d66.webp)

3. Alternatively, you can simply copy/paste the expressions below into expression editor:
   1. No: `vars.ResolutionRequired == "No"`
   2. Yes: `vars.ResolutionRequired == "Yes"`

**Approve invoice** task

1. Select the **Approve invoice** task, choose **Change element** from the toolbox, and select **User task**.
2. Open the properties panel and in the **Implementation** section and configure the following:
   * **Action**: `Create action app task`
   * **Action***: `Invoice.Approval action app`
   * **Task title**: `{your initials} Invoice approval`.
3. Configure the inputs by mapping the output from **Invoice received** message start event as inputs to the app task. Use the Variable search dialog to find the variables for the Data Fabric record **Id**.

**Resolve discrepancies task**

1. Select the **Resolve discrepancies**, choose **Change element** from the toolbox, and select **Service task**.
2. Open the properties panel and in the **Implementation** section, configure the following:
   * **Action**: `Start and wait for agent`.
   * **Automation**: `2-way matching agent`.
3. Configure the inputs by mapping the output from **Invoice received** message start event as inputs to the automation. Use the Variable search dialog to find the variables.
   * **InvNum**: Invoice received &gt; response &gt; Invoice number
   * **PoNum**: Invoice to PO matching &gt; PO number

**Resolve discrepancies agent outgoing gateway**

1. Select the gateway and expand the **Conditions** to enter the condition for the **Resolved** and **Rejected** paths and select the text entry picker to **Open expression editor** to enter the conditions.
2. Copy/paste the expressions below into expression editor.
   1. Resolved - `vars.Decision == "Resolved"`
   2. Rejected - `vars.Decision == "Rejected"`

**Notify vendor send task**

1. Select the **Notify vendor** task, choose **Change element** from the toolbox, and select **Send task**.
2. Open the properties panel and, in the **Implementation** section, configure the following:
   * **Action**: `Integration Servies - API execution`
   * **Connectors**: `Microsoft Outlook 365`
   * **Connection**: `{your outlook connection}`
      :::note
      Select `Connect to Microsoft Outlook 365` if you don’t already have a connection available.
      :::
   * **Activities**: `Send email`
   * **Trigger**: `Email sent`
3. In the **Filter** section, configure the Primary inputs for the Send email activity:
   * **To**: `{Invoice received` &gt; `response` &gt; `Invoice email}`
   * **Subject**: `Invoice rejected`
   * **Body**: Invoice rejected because {`Resolve discrepancies > message`}

   ![Implementation filter applied to the process view](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-implementation-filter-599685-e477336f.webp)

**Approve invoice outgoing gateway**

1. Select the gateway and expand the Conditions to enter the condition for the Approve and Reject paths and select the text entry picker to **Open expression editor** to enter the conditions.
2. Copy/paste the expressions below into expression editor:
   * Approve: `vars.Action == "Approve"`
   * Reject: `vars.Action == "Reject"`

**Post invoice to SAP automation**

1. Select the **Post invoice to SAP**, choose **Change element** from the toolbox, and select **Service task**.
2. Open the properties panel and in the **Implementation** section configure the following:
   * **Action**: `Start and wait for RPA workflow`
   * **Automation**: `Post Invoice to SAP`.
   * Configure the inputs by mapping the output from **Invoice to PO matching** task as inputs to the automation.
     + **PurchaseOrderId**: fail
     :::note
     We want this automation to fail so that we can fix runtime later.
     :::

Congratulations! You’ve now fully configured your first agentic process.

It's time for some debugging.

## Debug a business process

**Debug scenarios**

* Invoice Number starts with x &gt; No resolution required, go to Invoice Approval human-in-the-loop.
* Invoice Number starts with 1x &gt; Resolution required, go to Resolve Discrepancies Agent, Agent rejects.
* Invoice Number starts with 11 &gt; Resolution required, go to Resolve Discrepancies Agent, Agent resolves.

1. On the top-left of the page, select **Debug step-by-step**.

   ![Debug, Debug step-by-step, and Publish buttons with tooltip "Debug the project, pausing between activities"](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-docs-image-597366-1a867781.webp)

   :::note
   You can select **Test configuration** to confirm the input variables and connections used in the project.
   :::

2. Point to the left of the **Invoice to PO matching** task and select to add a breakpoint.

   ![Breakpoint indicator added to the Invoice to PO matching task](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-breakpoint-599815-ce1fef92.webp)

   :::note
   Configure breakpoints for your End events. This offers you enough time to inspect all variables before finishing the debug session.
   :::

3. Select **Next step** to move the execution past the Message start event.
4. Update the **response** Global variable for the Invoice received Message start event with the following response object, then select enter or tab to commit the change:

   ```
   {
       "Currency": "USD",
       "DueDate": "2025-02-14",
       "InvoiceDate": "2025-02-14",
       "InvoiceEmail": "petrodev71@gmail.com",
       "InvoiceNumber": "12345",
       "PONumber": "4551232",
       "TotalAmount": 10000,
       "VendorName": "Acme",
       "Source": 1,
       "Status": 6,
       "Id": "6F92ECF6-D1EA-EF11-90CB-6045BD93BF30",
       "UpdateTime": "2025-02-14T18:22:40.6233376Z",
       "CreateTime": "2025-02-14T12:48:19.3578548Z",
       "UpdatedBy": {
           "Email": "anthony.petro@uipath.com"
       },
       "CreatedBy": {
           "Email": "anthony.petro@uipath.com"
       }
   }
   ```

   ![global variables response](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-global-variables-response-599828-3db11c10.webp)
5. Select the expander to inspect and/or further change the values.

   ![Variable editor showing the invoice response object fields](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-edit-variables-599835-0f929b2d.webp)

6. Select **Update 1 variables** and **Update variables** in the dialog to commit the changes.
7. Select **Next step** or **Continue** to move the execution to the end with the new values.

Congratulations! You’ve fully debugged your first agentic process.

It's time to publish and deploy your process.

## Publish and deploy a complex process

1. Select **Publish** to publish the process. This requires publishing the entire solution the process is part of.

   ![Publish dialog showing the Location selector](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-publish-solution-599845-d384cbea.webp)

2. Read [Publishing and deploying solutions](https://docs.uipath.html/#PUBLISHING-AND-DEPLOYING-SOLUTIONS) for the steps to publish to Orchestrator.
3. Navigate to Orchestrator, and in the **Automations** tab, and select **Add process**.

   ![Add process button in the Orchestrator Automations tab](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-add-process-599874-84d5dba7.webp)

4. On the Connect to Microsoft Outlook 365 screen, select **Connect**.
5. Use your email credentials to complete the connection. The new connection will be automatically selected,.
6. Select **Next**.
7. Enter `{your initials} Invoice Processing` for the Display Name and choose **Create**.

Congratulations! You’ve now fully deployed your first agentic process!

It's time for some runtime instance management.

## Manage a business process

1. Navigate to Maestro home page.
2. In the **Process instances** view, choose `{your initials} Invoice Processing` to open the **All instances** view for your process.

   ![all instances view complex process](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-all-instances-view-complex-process-599937-67722a4d.webp)

3. You can select the model background to see **Global variables**, **Incidents**, **Action history**, as well as the **Execution trail**. You can select a node in the model or the **Execution trail** to inspect **Details** and **Variables** for that execution step.

      :::note
      You need to action any human-in-the-loop steps in Action Center if execution is paused there.
      :::

   Congratulations! You’ve fully managed your first agentic process,

It's time to fix your broken process.

## Fix a business process

For this exercise, cause a failure in execution so you can use the instance management to recover.

**Prepare failed instance**

1. Open a new Tab and navigate to Data Fabric &gt; APInvoice &gt; Data and add a record that has Invoice Number that starts with 2xxxx to ensure we get to the **Post invoice to SAP** step.

      :::note
      If you are in a shared environment, you can use an existing record that has **CreatedBy E-mail** that matches the filter you configured.
      :::

2. Navigate to your process **All instances** page, select the refresh button for the list and choose the latest instance.
3. When the execution is paused on a human-in-the-loop step, you must open Actions (formerly Action Center) to assign and complete the task.

   ![Invoice approval human-in-the-loop task in Action Center](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-invoice-approval-hitl-599963-977bc101.webp)

4. Open a new browser tab and select **Actions** in the left navigation menu.

   ![Actions section in the left navigation menu](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-axctions-599970-ee2d4cba.webp)

5. Select **Inbox**, then go to **Unassigned**.
6. Find and select your task and choose **Assign to self**.

   ![Assign to self button on an unassigned task](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-assign-to-self-599975-08079f87.webp)

7. Find your task in **Pending** and select **Approve** once the form load.

**Fix failed instance**

1. Go back to your agentic process tab, wait for **Post invoice to SAP** step to fail, and select on the node or the execution step. Note the **Errors** and **Variables**.
2. Update the variable to fix the input by changing **‘fail’** to **‘1234’** and select **Save**.
3. Select **Update 1 variable** to update the variable and add a **Comment**.
4. In the **Action History** tab, select **Retry**, add a comment and choose **Retry instance** to retry the step with the new variable. Watch the instance complete.

Congratulations! You successfully fixed a broken instance.

## Migrate to a new version of a business process

Fix the issue created in the previous section so it doesn’t happen again.

**Prepare failed instance**

1. Open a new Tab and navigate to Data Fabric &gt; APInvoice &gt; Data and add a record that has Invoice Number that starts with 2xxxx to ensure we get to the **Post invoice to SAP** step.

      :::note
      If you are in a shared environment, you can an existing record that has **CreatedBy E-mail** that matches the filter you configured.
      :::

2. Navigate back to your to **All instances** page, select the refresh button for the list and choose the latest instance.
3. When execution is paused on a human-in-the-loop step, you must open Actions (formerly Action Center) to assign and complete the task.
4. Open a new browser tab and select **Actions** in the left navigation menu.
5. Select **Inbox**, choose **Unassigned**, select your task, and choose **Assign to self**
6. Find your task in **Pending** and select **Approve** once the form loads.
7. Go back to your Maestro tab, wait for the **Post invoice to SAP** step to fail, and then select the node or the execution step.

**Update process version for repair**

1. Open `{your initials} Invoice Processing` process in UiPath Studio.
2. Fix the broken **Post invoice to SAP** step by configuring a PO number as input.
3. Select the **Post invoice to SAP** and open the properties panel.
4. In the **Inputs** section configure the inputs by mapping the output from **Invoice to PO matching** task as inputs to the automation.
   * **PurchaseOrderId**: `Invoice to PO matching` &gt; `PoNum`.
5. Publish the process to the Tenant feed.
6. Find your process in Orchestrator and select **Upgrade to latest version** from the menu.
7. Navigate back to Maestro, go to your process and your running instance.
8. This time, instead of fixing the variable, use the **Migrate** option.
9. Select the new version of your process, add a comment, and choose **Migrate instance**.

   ![Migrate instance dialog with Target version selector and comment field](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-migrate-instance-598013-c83ed9e9.webp)

10. Now you need to inform the engine to continue processing on the new version. Select **Retry**, add a comment, and choose **Retry instance** to continue execution which will now complete successfully.

Congratulations! You’ve successfully migrated a running instance to a new version.
