> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add a Delete button to delete records

> Add a Delete button to an Appian record type by building a deletion ProcessModel, attaching it as a related action, and optionally disabling it in the Summary view.

You can add a **Delete** button that lets users delete a record and its attachments from an Appian record type.

## Create a ProcessModel

<Steps>
  <Step title="Create a new ProcessModel">
    1. Open the ABBYYFlexiCapture application in Appian Designer and click **New → ProcessModel**.
    2. In the dialog box that opens, complete the **Name** field and specify the path to the folder where the process is to be saved.
    3. Click **Create & Edit**.
  </Step>

  <Step title="Remove the unused nodes">
    Modify the process configuration by deleting the following nodes on the **Process Modeler** tab:

    * **Start Event**
    * **End Event**
    * **XOR**
    * **Delete Folder**
    * **Delete Document**
    * **Delete from Data Store Entities**

    <Note>
      You can also double-click a node to modify it.
    </Note>
  </Step>

  <Step title="Create a confirmation interface">
    1. Return to **Appian Designer** to add a dialog box that prompts the user to confirm record deletion.
    2. Click **New → Interface** and specify a name for the interface.
    3. Click **Create & Edit**.
  </Step>

  <Step title="Add the confirmation expression">
    In the code editor that opens, switch from **Design View** to **Expression View** and paste the following expression:

    ```text theme={null}
    =a!formLayout(
        label: "Delete?",
        firstColumnContents: {
            a!paragraphField(
                labelPosition: "COLLAPSED",
                readOnly: true,
                value: "Submitting this form will delete your record and its attachments. The data will no longer exist or be visible in Tempo. After deletion, it is recommended to return to the records list, as this record will become unavailable."
            )
        },
        buttons: a!buttonLayout(
            primaryButtons: {
                a!buttonWidgetSubmit(
                    label: "Delete",
                    style: "PRIMARY"
                )
            },
            secondaryButtons: {
                a!buttonWidgetSubmit(
                    label: "Cancel",
                    style: "NORMAL",
                    value: true,
                    saveInto: ri!cancel,
                    skipValidation: true
                )
            }
        )
    )
    ```
  </Step>

  <Step title="Add the cancel input variable">
    In the **Interface Input** dialog box, add a `cancel` variable of type **Boolean**.
  </Step>

  <Step title="Add the process model variables">
    1. Save the interface and return to editing the process model.
    2. Click **File → Properties** and add the following variables on the **Variables** tab:
       * `recordId` of type **Number** (Integer)
       * `DataStoreEntity` of type **Data Store Entity** (a constant linking the data store to the data type)
  </Step>

  <Step title="Attach the confirmation interface">
    1. Open the **Process Start Form** tab, select the **Select an interface** option, and add the interface you created to ask for user confirmation when deleting a record.
    2. In the dialog box that opens, click **Yes** to import the interface variables into the list of process variables.

    You can then use the added variables in the process nodes:

    | Node                                | Description                                                                                                                                                                                                                                                                                               |
    | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | **Cancel (XOR)**                    | Routes the flow based on the user's choice. If the user clicks **Cancel**, the flow goes to the **End Event** node; otherwise, it goes to the **Delete Doc?** node.                                                                                                                                       |
    | **Delete Doc?**                     | Checks whether the folder linked to the record being deleted contains any documents, using the condition `=length(folder(pv!recordId, "documentChildren")) > 0;`. If the folder is empty, it is deleted; otherwise, the documents in the folder are deleted first, and then the folder itself is deleted. |
    | **Delete Document**                 | Deletes all documents it receives as input. The `folder` method returns the list of documents with the `documentChildren` parameter: `=folder(pv!recordId, "documentChildren")`.                                                                                                                          |
    | **Delete Folder**                   | Deletes a folder based on its identifier: `=pv!recordId`.                                                                                                                                                                                                                                                 |
    | **Delete from Data Store Entities** | Deletes records from the data store. The node receives the constant that links the data store, the data type (of custom type Table), and the record ID: `={{entity: pv!DataStoreEntity, identifiers: pv!recordId}}`.                                                                                      |
  </Step>

  <Step title="Save and publish the process">
    After you finish configuring the process, click **File → Save & Publish**, or press **Ctrl+Alt+S**.
  </Step>
</Steps>

## Add the process model to a record type

Add the process to the record type as a related action.

<Steps>
  <Step title="Open the record type">
    In Appian Designer, open **Record Type**.
  </Step>

  <Step title="Create a related action">
    1. In the dialog box that opens, click **New Related Action**.
    2. Complete the **ProcessModel** field (enter the name of the process you created).
    3. Specify the input variables of the process:
       * For **Credit Card Application**: `Constant_CreditApplication_DSE`
       * For **Account Payable Records**: `Constant_invoiceProcessing_DSE`
  </Step>

  <Step title="Add the related action to the record view">
    Add the new related action to the appropriate **View Record Type**.
  </Step>
</Steps>

Now, when viewing records on the **Summary** tab in Tempo, a **Delete** button appears at the top. When the user clicks this button, a confirmation dialog box asks whether they really want to delete the record. Clicking **Yes** in this dialog box deletes the record.

<Note>
  The user needs to refresh the browser window to confirm that the record has been completely deleted.
</Note>

## Disable the Delete action in the Summary View

To make the deletion button unavailable to the user, disable the **Delete** action in the **Summary View** properties.

<Steps>
  <Step title="Open the application">
    Open the ABBYYFlexiCapture application in Appian Designer.
  </Step>

  <Step title="Open the record type">
    Open the record type that you want to modify.
  </Step>

  <Step title="Disable the related action shortcut">
    In the dialog box that opens, click **Summary View** and disable the **Related Action Shortcuts** option next to the **Delete** action.
  </Step>

  <Step title="Save the changes">
    Click **OK** and save the changes you made to the record type.
  </Step>
</Steps>

Now, when records are viewed in Tempo, the **Delete** button no longer appears.
