SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Delete a Customer Record in an MDK App

Allow the user to delete a customer record in an MDK app.

Overview

You will learn

  • How to delete a customer record
  • How to store changes locally on Mobile app and sync these changes with backend
Jitendra Kansal J Jitendra Kansal August 21, 2026
Created on October 15, 2022
Contributors

More from Jitendra Kansal

See all 34 tutorials by Jitendra Kansal →

Prerequisites

Steps

Intro

You may clone an existing metadata project from the MDK Tutorial GitHub repository to start with this tutorial.


Delete Customer Record App Overview
Delete Customer Record App Overview

Step 1 Add a trash button to customer details page

You will add an action bar item to the Customer Detail page called Trash and link it to an event.

  1. In Customers_Detail.page, drag and drop an Action Bar Item to the upper right of the action bar.

    Action Bar Item Dropped On Detail Page
    Action Bar Item Dropped On Detail Page

    Action Bar Item is a button that users can use to fire actions when pressed. You can add an Action Bar Item only to the Action Bar (at the top of the page).

  2. Click the link icon to open the object browser for the System Item property.

    Double click the Trash type and click OK.

    Trash System Item Selected In Object Browser
    Trash System Item Selected In Object Browser

  3. Navigate to the Events tab. Click the dotted icon for the OnPress property and select the Create a rule/action.

    OnPress Event Create Rule Action
    OnPress Event Create Rule Action

  4. Select the Object Type as Rule and keep the default Folders path.

    Rule Object Type Selection
    Rule Object Type Selection

    You could link OnPress property directly to OData delete action directly instead to this JavaScript file. Idea of linking to JavaScript file is to let you understand another way to achieve similar functionality.

  5. In the Basic Information step, enter the Rule name as Customers_DeleteConfirmation and click Finish to complete the rule creation process.

    Delete Confirmation Rule Name Entry
    Delete Confirmation Rule Name Entry

  6. Replace the generated code with below snippet.

    JavaScript
    /**
    * Describe this function...
    * @param {IClientAPI} context
    */
    export default function Customers_DeleteConfirmation(context) {
        return context.executeAction('/demosampleapp/Actions/Customers_DeleteConfirmation.action').then((result) => {
            if (result.data) {
                return context.executeAction('/demosampleapp/Actions/Customers_DeleteEntity.action').then(
                    (success) => Promise.resolve(success),
                    (failure) => Promise.reject('Delete entity failed ' + failure));
            } else {
                return Promise.reject('User Deferred');
            }
        });
    }

    In above code there are references to Customers_DeleteConfirmation.action and Customers_DeleteEntity.action , those don’t exist in your metadata project yet. You will create these actions in next steps.

    Missing Action References In Rule Code
    Missing Action References In Rule Code

  7. In the above rule, double-click on the red line highlighting missing reference for Customers_DeleteConfirmation.action. You will notice a bulb icon suggesting some fixes, click on it, select MDK: Create action for this reference, and click Message Action.

    Creating Message Action From Missing Reference
    Creating Message Action From Missing Reference

  8. Provide the below information in the Customers_DeleteConfirmation.action:

    FieldValue
    MessageDelete current entity?
    TitleDelete Confirmation
    OKCaptionOK
    OnOK--None--
    CancelCaptionCancel
    OnCancel--None--

    Delete Confirmation Action Properties
    Delete Confirmation Action Properties

    When user taps or clicks the Trash icon on the Customer Detail page, a message will be displayed to confirm if user wants to delete current record. On it’s confirmation, Customers_DeleteEntity.action is executed.

  9. Similarly, fix the path reference for the missing Customers_DeleteEntity.action. Switch back to the Customers_DeleteConfirmation.js or open it again if it was closed. Double-click on the red line highlighting missing reference for Customers_DeleteEntity.action. You will notice a bulb icon suggesting some fixes, click on it, select MDK: Create action for this reference, and click ODataService DeleteEntity Action.

    Creating Delete Entity Action From Reference
    Creating Delete Entity Action From Reference

  10. Provide the below information in the Customers_DeleteEntity.action:

    PropertyValue
    ServiceSelect com_sap_edm_sampleservice_v4.service from the dropdown
    EntitySetSelect Customers from the dropdown
    ReadLinkclick link icon and double click readLink

    Delete Entity Action Properties
    Delete Entity Action Properties

    This action will store deleted record locally for an offline application or delete directly back to the backed for online applications.

    The readLink is a direct reference to an individual entity set entry.

    You can find more details about Delete Entity Action.

Step 2 Define Success and Failure actions
+
Step 3 Deploy the Project
+
Step 4 Run the Project
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Add a trash button to customer details page 2. Define Success and Failure actions 3. Deploy the Project 4. Run the Project
Next