# Control Line Item Deletion

Control the deletion of saved line items based on their status by specifying a Boolean field that determines whether deletion is allowed. If the specified field value is true, the delete button will be disabled for the corresponding line item.

<figure><img src="https://3800415611-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNuSjRiJMvVhtdzNDzWBi%2Fuploads%2FxHCKIemidjlLq0NDe0Gb%2FLineItem_Deleted.png?alt=media&#x26;token=77f95087-65e3-4ff2-8bd3-1ad28a92a855" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
DelDeletion control applies only within the Line Item Editor and does not affect Salesforce internal processes like API operations, Data Loader, or manual deletion.
{% endhint %}

### Example: Restrict Deletion of Approved Opportunity Products

{% hint style="info" %}
This example demonstrates the configuration of a Line Item Editor for Opportunity Products:

* **Parent:** Opportunity
* **Line Item:** OpportunityLineItem
* **Lookup:** PricebookEntry
  {% endhint %}

For Opportunity Products linked to an Opportunity, deletion should be restricted when the product is in an approved state. To configure this, the `Approved__c` field is used to control deletion.

#### Builder Setup

Set the `Approved__c` field as the deletion control field in the builder. Enter the API name of the field into the Deletion Control Field setting.

<figure><img src="https://3800415611-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNuSjRiJMvVhtdzNDzWBi%2Fuploads%2Fq0t6IJoJXQWzfQgHvrk5%2FLineItem_DeleteControl_Ex.png?alt=media&#x26;token=2017bf3d-ad95-4382-b641-8ce77928cd65" alt=""><figcaption></figcaption></figure>

#### Result

When the `Approved__c` field value is true, the delete button is hidden, preventing deletion of the corresponding line item.

<figure><img src="https://3800415611-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNuSjRiJMvVhtdzNDzWBi%2Fuploads%2FnMfVjfXEnbUTrTebVPw2%2FLineITem_Delete_Result.png?alt=media&#x26;token=df8f1661-8911-439b-ae25-e0cca1c4e62e" alt=""><figcaption></figcaption></figure>
