# Example of the X-Ray Workflow

This example shows how to add tracking for tasks in a process running on ProcessMaker platform. Here is the information we have regarding these tasks:

* Each task has a **status.**
* Each task has a **parent request** to which it belongs.
* Both the status and parent request information are visible in the UI.
* This information should be captured using X-Ray.

To track the tasks using the X-Ray desktop tool, following configuration is required:

1. [Add Application, Window, and Structured Process](#add-application-window-and-structured-process)
2. [Configure UI Data Collection](#configure-ui-data-collection)

## Add Application, Window, and Structured Process

### Step 1: Add ProcessMaker Platform as an Application

1. Navigate to **Admin Panel → Configure Data Collection → Track New Application**.
2. Add a new application and name it **ProcessMaker**.
3. After that, create a new data collection rule for the application.\
   Since a typical URL for the platform might look like `https://mycompany.processmaker.net/`, you can use `processmaker.net` as a keyword to search within the URL.<br>

   <div align="left"><figure><img src="https://content.gitbook.com/content/8GkXjeUIZVdsIJygBmnf/blobs/3fWkbkr4nYC42MttopgZ/Data%20Collection%20Rules.png" alt=""><figcaption></figcaption></figure></div>

### Step 2: Add a Task Window

Follow these steps to track the task window and categorize it correctly:&#x20;

1. Identify the relevant URL pattern. A typical task window URL on the platform is \ <mark style="background-color:purple;">`https://mycompany.processmaker.net/tasks/46027/edit`</mark>
2. Notice that the `/tasks/` part of the URL is key to identifying task pages.
3. Navigate to the **Window-Level Data Collection** tab and click **Add New Window**.
4. Name the window **Task (an alternate name can be used as well).**
5. Then, add the appropriate data collection rule for the window using `/tasks/` as the identifier.<br>

   <div align="left"><figure><img src="https://content.gitbook.com/content/8GkXjeUIZVdsIJygBmnf/blobs/5OOgbd4HkNbo9avT3lmR/Data%20Collection%20rules%20for%20tasks.png" alt=""><figcaption></figcaption></figure></div>

### Step 3: Add a Structured Process for the Task Object

Follow these steps to create a structured process for the task,&#x20;

1. Navigate to the **Structured Process Data Collection** tab.
2. From the following URL \ <mark style="background-color:purple;">`https://mycompany.processmaker.net/tasks/46027/edit`</mark>\
   we can identify that <mark style="background-color:purple;">`46027`</mark> is the unique process ID for the currently open task. In process data collection, this unique number must be tracked.
3. In the **Business Processes** section, click the **Add New** button.
4. In the **Add New Rule** section, apply the same data collection rule that was set for the task window, ensuring the task’s unique process ID is captured.<br>

   <div align="left"><figure><img src="https://content.gitbook.com/content/8GkXjeUIZVdsIJygBmnf/blobs/5HeGIH4UjXGD6ThVsPBb/Structure%20process%20data%20collection.png" alt=""><figcaption></figcaption></figure></div>
5. The keyword preceding the task ID is `/tasks/`, so add this keyword to the **URL path before process ID** field.&#x20;
6. Additionally, set the **Process Name**. For example, **ProcessMaker Task**.

   <div align="left"><figure><img src="https://content.gitbook.com/content/8GkXjeUIZVdsIJygBmnf/blobs/coOLLTbtu6mhbhvxaPCk/Process%20identifier%20collection.png" alt=""><figcaption></figcaption></figure></div>

***

## Configure UI Data Collection

In addition to tracking the task, it's also important to capture details like the task's **Status** (e.g., *In Progress* or *Overdue*) and the **Parent Request** linked to the task. While this information isn’t included in the URL or title, it is displayed within the UI.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeafrfxG73rVAbW3y9klN3tqYFv2jl_tY9qh1v2XljDJv2XSjE5RxoSiUNgbPq3U-5kRrS7PZ7unCkd3rKEehKz5TRt5yaEAbOP5wUIS_ngCVAEew6yvQp4Kn9xanORwgdYR_zvUAZuORnfoPyKxPgnlh5Y?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

To collect these values, **Reactions** can be configured to retrieve the necessary data from the UI elements. Follow these steps to configure **Reactions**:

### Step 1: Capture the X-Ray

1. Navigate to **Admin Panel → Configure Data Collection → X-Ray Tooling**.
2. If the toolchain is not yet installed, follow the detailed instructions provided in [Data Collection with X-Ray](https://processmaker.gitbook.io/worfellow/8t05gI5NaT1hoVDtEm3k/defining-data-collection/data-collection-with-x-ray).
3. Once installed, open **workfellow\_x\_ray.exe**.
4. Open any task in the ProcessMaker platform to use as an example for the configuration process.
5. Press **Alt + A** to capture an X-ray of the task page.

### Step 2: Open The X-Ray With Desktop Tool

1. Launch **desktop.exe**.
2. Locate the **X-Ray** folder on your computer and open it.
3. You should now see the captured X-ray from the task page displayed in the desktop tool.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe8N5pyFJUflWENbg_b6X-i1xkp3Mqt87XDPYHBCED_69gIEz2cJlKc14fw9psAUUfa3e0iQgSRpVHNg1y4f1Yfg1nIL0W-C4loStgkgKKAm3tCCUYCt0AjrrzfJsutpPWr52t7V8P94d5TLlrwsrV3E9Fn?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

### Step 3: Locate The UI-Elements from the X-Ray

1. In the example X-ray shown above, the task status is **Overdue** and the parent request is **#458 Budget Allocation 2024**. The goal is to find the path to these UI elements within the X-ray tree.
2. Starting with the status value, search for "OVERDUE" by filtering the element name.
3. Click **Filter** and input the search filter:\ <mark style="background-color:purple;">`"OVERDUE" == Name`</mark>
4. Click **Apply** and then check the **Show Parents** box. The search should result in one element corresponding to the status value.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcrtGELQj0UsbFSK9SZ88cPvA9MZ8qf1mSiHKPppLWpZ0OXbyvzLG4G0aqaZWzYFFbByamAQeb9aHLY62DamWhdmbLQAg4qoKWM2o8SpnQep2Y6PmyEkxu2YYozWOHylXV944b8ETUT2AUWJA88SuwWkMk?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

5. Copy the result pattern from the **Pattern Window**:

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXem9GKortcIo7pgRlpx49E2qDZueD2GJ13vnMDHBSmRugEbvNlTA5JoSsQzP14P7rEYWJCFZSXiI-lvE75_ElX7zbv6eoR1NAZnswynA0Qa27lLj-nB6C6Sxzhs4B7RZ-nhl_rLBwmdcZnPM692HPPoHWWE?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

6. Similarly, locate the request name. In the X-ray screenshot, the request name is **#458 Budget Allocation 2024**. To simplify the search, look for the element containing **#458**, as it’s likely to always appear as part of the full request name.
   * Use the following search filter to quickly find the targeted element:\ <mark style="background-color:purple;">`"#458" in Name`</mark>

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcprY1WpUUoMu_OseLMlHmMAgAzAvcv0SEytAJ7sC4J9ev6Aqn6yG-hadTYg4VduUtubmvy_e7DvXRsJItcx81PrfzPBf0vbHFGjFhBrAOwnIRCadhjAkwoljz4FbzWO472k_VktPej6OzZFvP4w1OxtJLh?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

7. Similarly, copy the pattern for this element again.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc6bj8hVc8NHuVWUnbMmf2RRaUYq73XOdsG3PHUY7VTHmONeUDtkFresIW13PyksnIxuKM1vILr1mkCsg6Y01KG7QsKubTRAt4Cs5FEJn7wOMSrMIOY1R5okw6LFKZCTNrUf60BCmaPivnTOqR-HIuv7fs?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

### Step 4: Add The Reaction to the Admin Panel

Follow these steps to integrate these patterns into the data collection configurations:

1. Navigate to **Admin Panel → Configure Data Collection → Advanced Setup → X-Ray Tooling**.
2. Scroll to **Task 4**, find the **ProcessMaker** app, and click the **Add Reactions** button.

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcE-ySEN3KSu2t6c1nTYfwjyz6Q_2SQNY9-wWwASKklYRJfhr_3i9AKVFfHIFkt9SXi106eUwidzm-Z7jL_SX6XY2171gBCRd_QScgctMtfC9eSN0MFTBQQVZxkNFEb5D67eFRBUeinbVUXYvZ7s_K3DQc?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="563"><figcaption></figcaption></figure></div>

3. Select the **Window** for adding the **Reaction**.

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeVZMY_8TdKUOaTNZuBleRk4QGHJpOiCqprNUujFanF4stuUbQNa_GgB_stxrugUXeygLSdgIDs-GCMSQtV8TQ7xjsV7sLwRg2FpIqr7AowbEiLWlloKQEnQeP_9_HKe4FD_2POud8Bt0yRStdhj4QTF_2f?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="375"><figcaption></figcaption></figure></div>

4. Copy and paste the **Reaction** for the status field from the desktop tool.
5. Enter a name, and click **Save**.

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcbHC3O9yzGuZQ6xAstHIij-s9X_zF_q73rh-eJYdeSwNFvOP6sIPNlIlOQe-LBA3PfPBuzTOI8Pt3SQ1TOwMqsSLCsV-V7tq-avu0_cm98brw7s9Hb7ufXt87nBqpKt9gLl5r-UTY3L8GOkuQY-6EKEZo?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="375"><figcaption></figcaption></figure></div>

6. Repeat the same operation for the Parent Request:

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe2BW8OXCL3EUz1LeOi6zio8PFO6nDcRd4PR87olVNj0p79SXefMm3NNaznO0j8wIlfwJIpTeX5MHFxRHbQsNSKx-lv_nMUetMYh2dJOvLOUYiy_N1G0p2h0vh_nuFB07x9R20PEWE06DXUU8rQR-m1Pyc?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="375"><figcaption></figcaption></figure></div>

7. Once these patterns are saved, they are added to the data collection configuration. As a result, each time the user visits the Task page in the ProcessMaker application, these two values will automatically be captured during the visit.

### Step 5: Configure The UI values as Structured Process Dimensions

Now that the UI data is being collected, follow these steps to associate these values with the appropriate Structured Process as dimensions:

1. Navigate to **Admin Panel → Structured Processes**.
2. Locate the **ProcessMaker Task** process that was previously added.
3. Click the **Dimensions** link.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeA5GCZzo5oH94rPERUwPaTH2zLXKJfb39c4bAyv-habxun1xn4HWCkVfglVAPl8z61mNIxHTNNAiSf0W6MWgJL91NwsnXNkYPs8k_jajS-GJQcbi_9G4bKS3u7XYnKWgubOC1z993tl1RDtg0xOOiaw2Ji?key=PbqMiA9hfqYBiPDdSO3R4g" alt=""><figcaption></figcaption></figure>

4. Click the **Add a Custom Dimension** button.
5. Enter **Task Status** as the dimension name, and select the **Task Status** reaction from the key list.
6. From the **Type** setting, select **STEP\_SPECIFIC**, as the status of the task can change during the process.

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeJsgXQyJM_r_zGRJaxuxDTXNwvJrq2V5aT33CUQWlYE59X1IJqQi7fFIgM6yzKwCa-0UM2JJDcx9SNbmrMI3W4-82V9O70OQ8YjHH_ZN9Fie97OjM2OTPMW4bM1ws9VCf5pYHoJ17pd-5T4aW2KIDkOlo?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="375"><figcaption></figcaption></figure></div>

7. In a similar way, add **Parent Request** as a dimension and select **TRANSACTION\_SPECIFIC** as the type. Since the parent request number remains consistent throughout the request and it's more relevant to track the latest value for the entire transaction, this type is most suitable.

<div align="left"><figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcdSMNG5eBm1-RIf8mhL7AxKjIMA3YlxyRrD1yjn3aXbtRaaS1hz-Ved18Gxq9TxgdtiJuHtFDRbcAcXsz-DpovZ_dVSm-RvrTLiSj126h7p3DABfhKQBMj4eHmiD8pQDfvU5RwPXVe9YsY_FiCDZc4ihD9?key=PbqMiA9hfqYBiPDdSO3R4g" alt="" width="375"><figcaption></figcaption></figure></div>
