Skip to content

Entry Delete

The EntryDeleteCL class is responsible for managing the DELETE operation through the OData V2 model. This class eliminates the need for developers to concern themselves with fragments, user input validations, and value help creation when working on custom SAPUI5 applications or Fiori Elements extensions. The following section outlines the key features of the Entry Delete class.

Features

Attention

Please be advised that the majority of features available in the Entry Create class are also accessible in the Entry Delete class. However, please note that the original documentation was created on the Entry Create page. To view a list of available features, please refer to the Available Features section.

Use Case

Let's assume you have an EntitySet named Products, which is bound to a table. You would like to enable the end user to select a line from the table and delete the selected entity from the database through the OData V2 Model. To do so, you must follow these steps.

1) Should you wish for the user to view the data of the selected entity on a pop-up screen, it is necessary to create a .fragment.xml file that contains a dialog with form content (Simple, Smart, etc.) and call it from the controller or generate the dialog directly on the controller.

2) It is necessary to handle the selection of the table and the binding of the selected entity to the dialog or form.

3) It is essential to utilize the OData V2 Model to execute the deletion process.

The EntryDeleteCL class is responsible for executing all of the steps mentioned above.

Constructor

In order to utilise the functionality of EntryDeleteCL, it is necessary to initialise the object.

Parameter Type Mandatory Default Value Description
controller sap.ui.core.mvc.Controller Yes The controller object (usually this object)
settings object Yes
 entityPath string Yes The name of the EntitySet. It can start with a "/" (slash)
 initializer string | sap.ui.model.Context | EntityKeysT Yes This parameter identifies the table ID, context binding, or key values of the entity that will be deleted.
modelName? string No undefined The name of the OData V2 model which can be found on the manifest.json file. Leave this parameter undefined if the name of the OData model = "" (empty string)

There are three distinct methods for constructing an object from the Entry Delete class.

Constructor with a Table ID

The most straightforward method for utilizing the capabilities of the Entry Delete class is to construct an object with the ID of a table that you have on your XML view. This method offers several advantages.

1) The table row selected by the end user is automatically detected by the Entry Delete class, and the context binding of the selected row will be bound to the auto-generated dialog.

2) If no table row is selected by the end user, a default message is displayed in the sap.m.MessageBox.error to the end user.

Attention

Please note that this method supports only the table types and selection modes listed below. In the event that the selection mode of the table whose ID is being used for object construction is not supported, an error will be thrown by the library.

Tip

The default message displayed when the end user has not selected a row from the table yet can be modified using the setSelectRowMessage() method.

Supported Table Types

Table Type Selection Mode
sap.m.Table SingleSelect | SingleSelectLeft | SingleSelectMaster
sap.ui.table.Table Single
sap.ui.comp.smarttable.SmartTable Single
sap.ui.table.AnalyticalTable Single
sap.ui.table.TreeTable Single

Example

Let us consider an EntitySet named Products, which is bound to an sap.m.Table on the XML view. Our objective is to add an sap.m.Button to the header toolbar of the table. When the user selects a row from the table and presses the Delete Product button, a dialog will open with a Delete button so the user can view the data before it is deleted.

Delete Constructor Sample

Tip for TypeScript

The EntryDeleteCL<EntityT, EntityKeysT> class is a generic class and can be initialized with 2 types.

  • The EntityT type contains all properties of the EntitySet that is specified on the class constructor.
  • The EntityKeysT type contains the key properties of the EntitySet that is specified on the class constructor.

The EntityT type is used for the parameter of the function that is attached using the attachDeleteCompleted() method. This allows you to retrieve the data of the deleted entity after it has been successfully deleted.

The EntityKeysT type is utilized as one of the types of the initializer parameter in the class constructor.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteCategory() {
    // Initialize without a type and with the table id
    const entry = new EntryDeleteCL(this, {
      entityPath: "Categories",
      initializer: "tblCategories" // table id       
    }); 
  }

  public async onDeleteProduct() {
    // Initialize with a type and the table id
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: "tblProducts" // table id       
    }); 
  }

  public async onDeleteCustomer() {
    // Initialize with a model name and the table id
    const entry = new EntryDeleteCL(this, {
      entityPath: "Customers",
      initializer: "tblCustomers" // table id      
    }, "myODataModelName"); 
  }
}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL" // Import the class
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with the table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts" // table id                
          }); 
        },

        onDeleteCategory: async function () {
          // Initialize with a model name
          const entry = new EntryDeleteCL(this, {
            entityPath: "Categories",
            initializer: "tblCategories" // table id                 
          }, "myODataModelName");
        }
      });

    });

Constructor with a Context Binding

An alternative approach to constructing an object from the Entry Delete class is to utilise the context of the entity that will be deleted by the end user.

Example

Let us consider an EntitySet named Products, which is bound to an sap.m.Table on the XML view. Our objective is to add an sap.m.Button to the header toolbar of the table. When the user selects a row from the table and presses the Delete Product button, we will retrieve the context of the selected row and use it to construct an object from the Entry Delete class.

Delete Constructor Sample

Tip for TypeScript

The EntryDeleteCL<EntityT, EntityKeysT> class is a generic class and can be initialized with 2 types.

  • The EntityT type contains all properties of the EntitySet that is specified on the class constructor.
  • The EntityKeysT type contains the key properties of the EntitySet that is specified on the class constructor.

The EntityT type is used for the parameter of the function that is attached using the attachDeleteCompleted() method. This allows you to retrieve the data of the deleted entity after it has been successfully deleted.

The EntityKeysT type is utilized as one of the types of the initializer parameter in the class constructor.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class
import MessageBox from "sap/m/MessageBox";
import Table from "sap/m/Table";

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteCategory() {
    // Get the selected item and warn the end user if no row was selected
    const selectedItem = (this.getView().byId("tblCategories") as Table).getSelectedItem();

    if (!selectedItem) {
      MessageBox.error("Please select a row from the table");
      return;
    }

    // Get the selected context
    const selectedContext = selectedItem.getBindingContext();

    // Initialize without a type and use the binding context
    const entry = new EntryDeleteCL(this, {
      entityPath: "Categories",
      initializer: selectedContext // binding context
    }); 
  }

  public async onDeleteProduct() {
    // Get the selected item and warn the end user if no row was selected
    const selectedItem = (this.getView().byId("tblProducts") as Table).getSelectedItem();

    if (!selectedItem) {
      MessageBox.error("Please select a row from the table");
      return;
    }

    // Get the selected context
    const selectedContext = selectedItem.getBindingContext();

    // Initialize with a type and use the binding context
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: selectedContext // binding context
    }); 
  }

  public async onDeleteCustomer() {
    // Get the selected item and warn the end user if no row was selected
    const selectedItem = (this.getView().byId("tblCustomers") as Table).getSelectedItem();

    if (!selectedItem) {
      MessageBox.error("Please select a row from the table");
      return;
    }

    // Get the selected context
    const selectedContext = selectedItem.getBindingContext();

    // Initialize with a model name and use the binding context
    const entry = new EntryDeleteCL(this, {
      entityPath: "Customers",
      initializer: selectedContext // binding context   
    }, "myODataModelName"); 
  }
}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL", // Import the class
    "sap/m/MessageBox"
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL, MessageBox) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Get the selected item and warn the end user if no row was selected
          const selectedItem = this.getView().byId("tblProducts").getSelectedItem();

          if (!selectedItem) {
            MessageBox.error("Please select a row from the table");
            return;
          }

          // Get the selected context
          const selectedContext = selectedItem.getBindingContext();

          // Initialize with the binding context
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: selectedContext // binding context     
          }); 
        },

        onDeleteCategory: async function () {
          // Get the selected item and warn the end user if no row was selected
          const selectedItem = this.getView().byId("tblCategories").getSelectedItem();

          if (!selectedItem) {
            MessageBox.error("Please select a row from the table");
            return;
          }

          // Get the selected context
          const selectedContext = selectedItem.getBindingContext();

          // Initialize with the binding context
          const entry = new EntryDeleteCL(this, {
            entityPath: "Categories",
            initializer: selectedContext // binding context               
          }, "myODataModelName");
        }
      });

    });

Constructor with Entity Keys

The final method for constructing an object from the Entry Delete class is to utilize the key values of the entity that will be deleted by the end user.

Example

For the purposes of this example, let us consider an EntitySet named Products with a single key property named ID, whose type is Edm.Guid. We would like to allow the end user to delete a specific entity with the key value: ID = "b2f0013e-418f-42aa-9a24-3770fe17ce18".

Tip

Please note that if the EntitySet is bound to a table, you can retrieve the values of the key properties of the selected row using the getBindingContext().getObject() method.

Info

The EntryDeleteCL class creates a binding context with the values of the specified key properties using the initializer parameter in the class constructor and subsequently binds the created context to the dialog.

Tip for TypeScript

The EntryDeleteCL<EntityT, EntityKeysT> class is a generic class and can be initialized with 2 types.

  • The EntityT type contains all properties of the EntitySet that is specified on the class constructor.
  • The EntityKeysT type contains the key properties of the EntitySet that is specified on the class constructor.

The EntityT type is used for the parameter of the function that is attached using the attachDeleteCompleted() method. This allows you to retrieve the data of the deleted entity after it has been successfully deleted.

The EntityKeysT type is utilized as one of the types of the initializer parameter in the class constructor.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteCategory() {
    // Prepare the key values of a specific entity
    const keyValues = {
      ID: "b2f0013e-418f-42aa-9a24-3770fe17ce18"
    };

    // Initialize without a type and use the key values as the initializer
    const entry = new EntryDeleteCL(this, {
      entityPath: "Categories",
      initializer: keyValues // key values of the entity
    });
  }

  public async onDeleteProduct() {
    // Prepare the key values of a specific entity
    const keyValues = {
      ID: "b2f0013e-418f-42aa-9a24-3770fe17ce18"
    };

    // Initialize with a type and use the key values as the initializer
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: keyValues // key values of the entity
    });
  }

  public async onDeleteCustomer() {
    // Prepare the key values of a specific entity
    const keyValues = {
      ID: "b2f0013e-418f-42aa-9a24-3770fe17ce18"
    };

    // Initialize with a model name and use the key values as the initializer
    const entry = new EntryDeleteCL(this, {
      entityPath: "Customers",
      initializer: keyValues // key values of the entity
    }, "myODataModelName"); 
  }
}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL"
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Prepare the key values of a specific entity
          const keyValues = {
            ID: "b2f0013e-418f-42aa-9a24-3770fe17ce18"
          };

          // Initialize with the entity set name and use the key values as the initializer
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: keyValues // key values of the entity
          });  
        },

        onDeleteCategory: async function () {
          // Prepare the key values of a specific entity
          const keyValues = {
            ID: "b2f0013e-418f-42aa-9a24-3770fe17ce18"
          };

          // Initialize with the entity set name and use the key values as the initializer
          const entry = new EntryDeleteCL(this, {
            entityPath: "Categories",
            initializer: keyValues // key values of the entity        
          }, "myODataModelName");          
        }
      });

    });

Select Row Message

If the object from the Entry Delete class is constructed using the Constructor with a Table ID approach, a default error message is displayed in an sap.m.MessageBox.error to the end user when the user has not yet selected a row from the table.

To change the default message, the setSelectRowMessage() method can be utilized.

Parameter Type Mandatory Description
message string Yes The message that is displayed when the end user has not selected a row from the table

Returns Description
string Returns the value that was set using setSelectRowMessage() method. Default value is Please select a row from the table.

Delete Entry

The deleteEntry(previewBeforeDelete: boolean = true) method establishes a connection between the context, determined by the initializer parameter in the class constructor, and the dialog that is either automatically generated or loaded from the fragment placed in the application files. Once the context is linked, the generated or loaded dialog is opened.

The deleteEntry() method utilizes the ODataMetaModel to determine the EntityType of the EntitySet designated through the constructor. It then generates the form with the properties in the same order as the OData metadata, in accordance with the EntityType.

Note

Please note that the labels are generated assuming that the naming convention of the EntityType is camelCase. For further details, please see the Label Generation section.

Attention

It is not possible to modify any of the properties of an EntitySet on the auto-generated dialog. This behaviour cannot be altered.

Warning

Please be advised that the deleteEntry() method must be called after any configurations have been made through the public methods of the Entry Delete class. Any configurations (form title, begin button text, etc.) made after the deleteEntry() method will not be reflected. As a best practice, the deleteEntry() method should be called at the end of your code block.

Note

The key properties with Edm.Guid type are not visible by default on the generated form. However, this behavior can be modified using the setDisplayGuidProperties() method.

Attention

Please be advised that the random UUID generation for properties with the Edm.Guid type is not available in the Entry Delete class.

By default, the deleteEntry(previewBeforeDelete: boolean = true) method generates a dialog and opens it with the bound context before the deletion is completed. The automatically generated dialog contains a Delete button. When the user presses the Delete button, a sap.m.MessageBox.confirm is displayed to the end user to complete the deletion process.

Tip

The automatically generated dialog opening step can be bypassed by setting the previewBeforeDelete=false parameter in the deleteEntry(previewBeforeDelete: boolean = true) method. With this configuration, the end user will only see a sap.m.MessageBox.confirm.

Method Parameters

Parameter Type Mandatory Default Value Description
previewBeforeDelete boolean No true If set to false, no dialog will be displayed by the end user. Only the confirmation MessageBox is displayed
Returns Description
Promise<void> Once the promise has been fulfilled, the bound entry can be retrieved using the getEntryContext() method with the object instantiated from the EntryDeleteCL class.

Info

The deleteEntry() method uses the default configurations when creating the dialog. However, these configurations can be modified using the public setter methods.

Default Values

Term Default Value Description Setter Getter
Naming Strategy NamingStrategies.CAMEL_CASE The default naming strategy is CAMEL_CASE setNamingStrategy() getNamingStrategy()
Resource Bundle Prefix antares The default resource bundle prefix is antares setResourceBundlePrefix() getResourceBundlePrefix()
Use Metadata Labels false The labels are not derived from the metadata, but rather generated. setUseMetadataLabels() getUseMetadataLabels()
Form Type FormTypes.SMART The SmartForm with SmartFields is generated as the default option. setFormType() getFormType()
Form Title Delete + ${entityPath} The entityPath parameter of the constructor is used setFormTitle() getFormTitle()
Begin Button Text Delete The default begin button text is Delete setBeginButtonText() getBeginButtonText()
Begin Button Type ButtonType.Reject The default button type is Reject setBeginButtonType() getBeginButtonType()
End Button Text Close The default end button text is Close setEndButtonText() getEndButtonText()
End Button Type ButtonType.Default The default button type is Default setEndButtonType() getEndButtonType()
Confirmation Text The selected line will be deleted. Do you confirm? The message displayed in the MessageBox.confirm setConfirmationText() getConfirmationText()
Confirmation Title Confirm Delete The title of the MessageBox.confirm/td> setConfirmationTitle() getConfirmationTitle()

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class
import Table from "sap/m/Table";
import MessageBox from "sap/m/MessageBox";

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteProduct() {
    // Initialize without a type and with a table id
    const entry = new EntryDeleteCL(this, {
      entityPath: "Products",
      initializer: "tblProducts"
    });

    // Call with no preview
    entry.deleteEntry(false); 
  }

  public async onDeleteCategory() {
    const selectedItem = (this.getView().byId("tblCategories") as Table).getSelectedItem();

    if (!selectedItem) {
      MessageBox.error("Please select a row from the table");
      return;
    }

    const selectedContext = selectedItem.getBindingContext();

    // Initialize with a type and a binding context
    const entry = new EntryDeleteCL<ICategory>(this, {
      entityPath: "Categories",
      initializer: selectedContext
    }); 

    // Call with the preview
    entry.deleteEntry();
  }

  public async onDeleteCustomer () {
    const selectedItem = (this.getView().byId("tblCustomers") as Table).getSelectedItem();

    if (!selectedItem) {
      MessageBox.error("Please select a row from the table");
      return;
    };

    const customerKeys = {
      ID: selectedItem.getBindingContext().getObject().ID
    };

    // Initialize without a type and with the key values
    const entry = new EntryDeleteCL(this, {
      entityPath: "Customers",
      initializer: customerKeys
    });

    // Call with the preview
    entry.deleteEntry();
  }
}

interface ICategory {
  ID: string;
  name?: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL", // Import the class
    "sap/m/MessageBox"
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL, MessageBox) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with a table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts"
          }); 

          // Call with no preview
          entry.deleteEntry(false);
        },

        onDeleteCategory: async function () {
          const selectedItem = this.getView().byId("tblCategories").getSelectedItem();

          if (!selectedItem) {
            MessageBox.error("Please select a row from the table");
            return;
          }

          const selectedContext = selectedItem.getBindingContext();

          // Initialize with a binding context
          const entry = new EntryDeleteCL(this, {
            entityPath: "Categories",
            initializer: selectedContext
          }); 

          // Call with the preview
          entry.deleteEntry();
        },

        onDeleteCustomer: async function () {
          const selectedItem = this.getView().byId("tblCustomers").getSelectedItem();

          if (!selectedItem) {
            MessageBox.error("Please select a row from the table");
            return;
          }

          const customerKeys = {
            ID: selectedItem.getBindingContext().getObject().ID
          };

          // Initialize with the key values
          const entry = new EntryDeleteCL(this, {
            entityPath: "Customers",
            initializer: customerKeys
          }); 

          // Call with the preview
          entry.deleteEntry();          
        }
      });

    });

The generated form with default values will be similar in appearance to the following example. However, it should be noted that the exact appearance may vary depending on the configurations and the EntityType properties of the EntitySet.

Delete Entry

Delete Entry Confirmation

Confirmation Text

To prompt the end user for confirmation before deleting data, a default confirmation message is displayed on a sap.m.MessageBox.confirm.

To change the default confirmation message, the setConfirmationText() method can be utilized.

Parameter Type Mandatory Description
text string Yes The message displayed in MessageBox.confirm before the deletion

Returns Description
string Returns the value that was set using setConfirmationText() method. Default value is The selected line will be deleted. Do you confirm?

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteProduct() {
    // Initialize with a type and with a table id
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: "tblProducts"
    });

    // Change the confirmation message
    entry.setConfirmationText("This line will be removed from the database. Do you want to continue?");

    // Call with no preview
    entry.deleteEntry(false); 
  }

}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL" // Import the class
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with a table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts"
          });

          // Change the confirmation message
          entry.setConfirmationText("This line will be removed from the database. Do you want to continue?");

          // Call with no preview
          entry.deleteEntry(false);  
        }
      });

    });

Confirmation Title

To prompt the end user for confirmation before deleting data, a default title is displayed on a sap.m.MessageBox.confirm.

To change the default title of the MessageBox, the setConfirmationTitle() method can be utilized.

Parameter Type Mandatory Description
title string Yes The title displayed in MessageBox.confirm before the deletion

Returns Description
string Returns the value that was set using setConfirmationTitle() method. Default value is Confirm Delete

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteProduct() {
    // Initialize with a type and with a table id
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: "tblProducts"
    });

    // Change the confirmation title
    entry.setConfirmationTitle("My Confirmation Title");

    // Call with no preview
    entry.deleteEntry(false); 
  }

}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL" // Import the class
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with a table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts"
          });

          // Change the confirmation title
          entry.setConfirmationTitle("My Confirmation Title");

          // Call with no preview
          entry.deleteEntry(false);  
        }
      });

    });

Attach Delete Completed

The Entry Delete class can call a function that has been attached with the attachDeleteCompleted() method after a successful deletion. This function will then receive the data of the deleted entity.

To attach a function, the attachDeleteCompleted() method can be utilized.

Setter (attachDeleteCompleted)

Parameter Type Mandatory Description
completed (data: EntityT) => void Yes The function that will be called after the successful deletion
listener? object No The default listener is the controller from constructor

Example

Suppose you want to receive a response after the successful deletion and take the necessary action.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class
import MessageBox from "sap/m/MessageBox";

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteProduct() {
    // Initialize with a type and with a table id
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: "tblProducts"
    });

    // Attach the function
    entry.attachDeleteCompleted(this.onDeleteCompleted, this);

    // Call with no preview
    entry.deleteEntry(false); 
  }

  // If possible, use the same type that is used in the constructor
  private onDeleteCompleted (data: IProducts) {
    const productID = data.ID;

    MessageBox.information(`The product with the following ID is removed: ${productID}`);
  }
}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL", // Import the class
    "sap/m/MessageBox"
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL, MessageBox) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with a table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts"
          });

          // Attach the function
          entry.attachDeleteCompleted(this.onDeleteCompleted, this);

          // Call with no preview
          entry.deleteEntry(false); 
        },

        // Handler function
        onDeleteCompleted: function (data) {
          const productID = data.ID;

          MessageBox.information(`The product with the following ID is removed: ${productID}`);
        }
      });

    });

Attach Delete Failed

In the event that the deletion of the entity is unsuccessful, the Entry Delete class can then call a function with a specific signature. The result of the deletion will then be passed to the attached function.

To attach a function, the attachDeleteFailed() method can be utilized.

Setter (attachDeleteFailed)

Parameter Type Mandatory Description
failed (response: ResponseCL<IDeleteFailed>) => void Yes The function that will be called after the deletion fails
listener? object No The default listener is the controller from constructor

An object constructed from the ResponceCL class passed as a parameter to the function. This object has 2 public methods.

Returns Description
object | undefined
    headers?: object The HTTP response headers.
    message?: string The HTTP response message.
    responseText?: string The HTTP response text.
    statusCode?: string The status code of the HTTP request.
    statusText?: string The HTTP status text.

Returns Description
string | undefined Returns the status code of the HTTP Request

Example

Suppose you want to receive a response after the unsuccessful deletion and take the necessary action.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Controller from "sap/ui/core/mvc/Controller";
import EntryDeleteCL from "ui5/antares/entry/v2/EntryDeleteCL"; // Import the class
import ResponseCL from "ui5/antares/entry/v2/ResponseCL"; // Import the ResponseCL class
import { IDeleteFailed } from "ui5/antares/types/entry/delete"; // Import the Delete Failed type
import MessageBox from "sap/m/MessageBox";

/**
 * @namespace your.apps.namespace
 */
export default class YourController extends Controller {
  public onInit() {

  }

  public async onDeleteProduct() {
    // Initialize with a type and with a table id
    const entry = new EntryDeleteCL<IProducts, IProductKeys>(this, {
      entityPath: "Products",
      initializer: "tblProducts"
    });

    // Attach the function
    entry.attachDeleteFailed(this.onDeleteFailed, this);

    // Call with no preview
    entry.deleteEntry(false); 
  }

  // If possible, use the IDeleteFailed type
  private onDeleteFailed (response: ResponseCL<IDeleteFailed>) {
    const statusCode = response.getStatusCode(); // get the status code
    const deleteResponse = response.getResponse(); // get the response

    if (deleteResponse) {
      MessageBox.error(deleteResponse.message);
    }
  }
}

interface IProducts {
  ID: string;
  name: string;
  description: string;
  brand: string;
  price: number;
  currency: string;
  quantityInStock: number;
  categoryID: string;
  supplierID: string;
}

interface IProductKeys {
  ID: string;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "ui5/antares/entry/v2/EntryDeleteCL", // Import the class
    "sap/m/MessageBox"
], 
    /**
     * @param {typeof sap.ui.core.mvc.Controller} Controller
     */
    function (Controller, EntryDeleteCL, MessageBox) {
      "use strict";

      return Controller.extend("your.apps.namespace.YourController", {
        onInit: function () {

        },

        onDeleteProduct: async function () {
          // Initialize with a table id
          const entry = new EntryDeleteCL(this, {
            entityPath: "Products",
            initializer: "tblProducts"
          });

          // Attach the function
          entry.attachDeleteFailed(this.onDeleteFailed, this);

          // Call with no preview
          entry.deleteEntry(false); 
        },

        // Handler function
        onDeleteFailed: function (response) {
          const statusCode = response.getStatusCode(); // get the status code
          const deleteResponse = response.getResponse(); // get the response

          if (deleteResponse) {
            MessageBox.error(deleteResponse.message);
          }
        }
      });

    });

Available Features

The EntryDeleteCL class is derived from the same abstract class as the EntryCreateCL class and contains the same methods. However, some of these functions are not applicable to the EntryDeleteCL class.

Warning

Please note that the default values for the available functions may differ.

The features listed below are identical to those available in EntryCreateCL. Methods can be accessed through the object constructed from the EntryDeleteCL class.

Tip

To access the documentation for a particular feature, please click on the name of the feature.

Feature Availability Default Value Remarks
Manual Submit
Disable Auto Dialog Close false
Label Generation
Resource Bundle Prefix antares
Naming Strategy CAMEL_CASE
Form Type SMART
Form Title Delete ${entityPath}
Form Grouping []
Custom Data []
Text In Edit Mode Source []
Begin Button Text Delete
Begin Button Type ButtonType.Reject
End Button Text Close
End Button Type ButtonType.Default
Confirmation Text The selected line will be deleted. Do you confirm?
Confirmation Title Confirm Delete
Properties with Edm.Guid Type The random UUID generation is not available. You can only modify the visibilities of the properties with Edm.Guid type
Form Property Order []
Excluded Properties []
Mandatory Properties
Readonly Properties [all properties] By default, all the properties are readonly and cannot be changed
Attach Submit Completed Please see Attach Delete Completed
Attach Submit Failed Please see Attach Delete Failed
Response Class Only available for Attach Delete Failed
Value Help
Validation Logic
Object Page
Custom Control
Custom Content
Custom Fragment