🎓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
You will add an action bar item to the Customer Detail page called Trash and link it to an event.
In Customers_Detail.page, drag and drop an Action Bar Item to the upper right of the action bar.
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).
Click the link icon to open the object browser for the System Item property.
Double click the Trash type and click OK.
MDK
Navigate to the Events tab. Click the dotted icon for the OnPress property and select the Create a rule/action.
MDK
Select the Object Type as Rule and keep the default Folders path.
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.
In the Basic Information step, enter the Rule name as Customers_DeleteConfirmation and click Finish to complete the rule creation process.
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
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
Provide the below information in the Customers_DeleteConfirmation.action:
Field
Value
Message
Delete current entity?
Title
Delete Confirmation
OKCaption
OK
OnOK
--None--
CancelCaption
Cancel
OnCancel
--None--
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.
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
Provide the below information in the Customers_DeleteEntity.action:
Property
Value
Service
Select com_sap_edm_sampleservice_v4.service from the dropdown
EntitySet
Select Customers from the dropdown
ReadLink
click link icon and double click readLink
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.
When the above OData action is executed, you may want to display messages on its success and failure behavior. For example, on its success, you may want to display a success message and allow any execution to continue. On its failure, you may want to display an error.
In the Customers_DeleteEntity.action, scroll down and expand the Common Action Properties section. Click the link icon to open the object browser for the Success Action and bind it to CloseModalPage_Complete.action.
MDK
Create a message action for displaying a message in case deleting of a customer fails. In the Customers_DeleteEntity.action, click the Create a rule/action icon for the Failure Action.
MDK
Keep the default selection for the Object Type as Action and Folders path.
MDK
In the Template Selection step, choose Message in Category | click Message | Next.
MDK
In the Base Information step, provide the below information:
Customers_DeleteEntity is the Action Result value of the Customers_DeleteEntity.action. This reference is used to pass the results to subsequent actions in the chain. These actions can reference the action result as needed. In this case if there is a failure, you access the error property of the action result to display the OData failure message.
This is the standard Binding Target Path (also called Dynamic Target Path) syntax used when you need to include a binding with other bindings or within a string as used in the message here.
You could exclude above expression and can just display a generic message.
Click Finish to complete the action creation process.
When Customers_DeleteEntity.action gets executed successfully then CloseModalPage_Complete.action will be triggered or if Customers_DeleteEntity.action fails then DeleteCustomerEntityFailureMessage.action will be triggered.
Step 3Deploy the Project
+
You will now deploy the updated project to your MDK client.
Click the Deploy option in the editor’s header area, and then choose the deployment target as Mobile Services .
MDK
Step 4Run the Project
+
Make sure you are choosing the right device platform tab above.
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
MDK
Tap Customers | tap any record | tap trash icon.
MDK
A confirmation dialog appears for user action, tap OK.
MDK
Since this is an Offline application, record has been removed from local store and deletion request has been added to request queue. This has to be sent or uploaded to the backend explicitly.
MDK template has added a Sync Changes option in the user menu on main page of the app to upload local changes from device to the backend and to download the latest changes from backend to the device. Actions | Service | UploadOffline.action & DownloadOffline.action.
Tap on Sync Changes in the user menu On Main page to push the local changes to the backend, a successful message will be shown once data is submitted.
MDK
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
MDK
Tap Customers | tap any record | tap trash icon.
MDK
A confirmation dialog appears for user action, tap OK.
MDK
Since this is an Offline application, record has been removed from local store and deletion request has been added to request queue. This has to be sent or uploaded to the backend explicitly.
MDK template has added a Sync Changes option in the user menu on main page of the app to upload local changes from device to the backend and to download the latest changes from backend to the device. Actions | Service | UploadOffline.action & DownloadOffline.action.
Tap on Sync Changes in the user menu On Main page to push the local changes to the backend, a successful message will be shown once data is submitted.
MDK
You can cross verify if this record has been deleted in the backend.
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 4
1. Add a trash button to customer details page2. Define Success and Failure actions3. Deploy the Project4. Run the Project
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.