SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

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

🎓 intermediate 20 min. Mobile Development Kit ClientIntermediateIosAndroidMobileSAP Business Technology PlatformSAP Mobile ServicesSAP Build CodeSAP BuildSAP Business Application Studio

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 April 1, 2026
Created by October 15, 2022
Contributors

Prerequisites

Steps

Intro

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


MDK
MDK

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.

    MDK
    MDK

    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.

    MDK
    MDK

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

    MDK
    MDK

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

    MDK
    MDK

    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.

    MDK
    MDK

  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.

    MDK
    MDK

  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.

    MDK
    MDK

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

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

    MDK
    MDK

    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.

    MDK
    MDK

  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

    MDK
    MDK

    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

Learn more →