cancel
Showing results for 
Search instead for 
Did you mean: 

FIORI Elements - Capturing response object after execution of SAVE button

sun197895
Participant
1,238

Hi,

My app is based on FIORI elements. Right now when I edit the Object page and click on SAVE button, it all saves fine but I want to capture the response object after Save action is complete.

Here SAVE is a standard action/button so may I know where exactly in the controller I need to write logic to capture the response object (after SAVE action is complete and control comes back to front-end)\

Thanks!

View Entire Topic
arunbharathi
Employee
Employee

Hello,

If the application is non-draft then attach a handler to the extension API method AttachAfterSave.

For a draft-based application, the extension API method attachAfterActivate can be used.

Thanks,

Arun

sun197895
Participant
0 Kudos

Hi,

This I already tried and it is not working. Below is the snippet of my code.

The below AfterSave event is getting triggered the moment I click on 'Save' button. But what I am expecting is to first process the 'Save' event (create a record) and then when control comes back to the UI I want the code in the 'AfterSave' to be executed. I basically want to do a oData read on an entity after the 'Save' functionality is complete.

Strange part is, 'beforeSaveExtension' function is also working the same way (which of course is expected based on the function name). Basically, AfterSave & beforeSaveExtension are getting triggered the moment I click on 'Save' button.

onAfterRendering: function() {
    this.extensionAPI.getTransactionController().attachAfterSave(function() { 
        sap.m.MessageBox.show("Testing After Save Event"); 
        // Do something here, like a odata read, etc 
     });
}
arunbharathi
Employee
Employee
0 Kudos

Hi , these events return a promise in which the required method can be executed as below.

oEvent.activationPromise.then(()=>{
       sap.m.MessageBox.show("Testing After Save Event"); 
});

sun197895
Participant
0 Kudos

Hi,

Looks like extensionAPI is not supported in 1.60.18 version. In local webide if I point the SAPUI5 version to 1.60.18 it does not trigger extensionAPI methods but when pointed to anything above 1.65 it works fine. Unfortunately my dev system is on 1.60.18.

May I know any workaround for this version ? I mean, when user clicks on SAVE button, I want to validate the changes made by the user before I let the Save request execute. Thanks.

tursko
Participant
0 Kudos

Thanks for your help! Below is the code I used.

_afterActivate: function(oEvent) {
oEvent.activationPromise.then(() => {
// NOTE: This is called after the user save's their changes (activation)
MessageToast.show("Testing After Activate Event");
})
},
onAfterRendering: function () {
// Call custom function to perform actions after save of draft
this.base.templateBaseExtension.getExtensionAPI().getTransactionController().attachAfterActivate(this._afterActivate);
}