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.
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).
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
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
Select the Object Type as Rule and keep the default Folders path.
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.
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.
Missing Action References In Rule Code
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
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--
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.
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
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
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.
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.
Success Action Binding In Delete Entity
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.
Failure Action Create Icon Selected
Keep the default selection for the Object Type as Action and Folders path.
Default Action Object Type Selection
In the Template Selection step, choose Message in Category | click Message | Next.
Message Template Selection Step
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 .
Deploy To Mobile Services Option
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.
Android Check For Updates New Version Popup
Tap Customers | tap any record | tap trash icon.
Android Customer Record Trash Icon
A confirmation dialog appears for user action, tap OK.
Android Delete Confirmation Dialog
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.
Android Sync Changes Success Message
Tap Check for Updates in the user menu on the Main page, you will see a New Version Available pop-up, tap Now.
iOS Check For Updates New Version Popup
Tap Customers | tap any record | tap trash icon.
iOS Customer Record Trash Icon
A confirmation dialog appears for user action, tap OK.
iOS Delete Confirmation Dialog
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.
iOS Sync Changes Success Message
You can cross verify if this record has been deleted in the backend.
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.