Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)
Answered

Call Methods of another App

Hello everybody!


I have three apps. A and B and C.


App A and B holds some data, which are not synchronized with the backend. App C should be used as the central synchronization point for the user. So, I want to call the ajax sync Methods of App A and B in App C. 


App A and B are loaded and running in background. How can I execute now the ajax sync methods?


I already tried it with

 AppCache.Load('APP_A',{                                                  load:'getOnlineAjaxSync'})


But it seems, that the only Methods which are working here are 'init' or download.


Best regards,

Fabian 


Best Answer

Hi Micael,


you can do something like this:


Register your Method in app B to the "sap.n." namespace. ( Pre-condition: Apps need to run within the launchpad)    

if (sap.n) {
    sap.n.Shell.attachBeforeDisplay(function() {

        if (!sap.n.Functions){
               sap.n.Functions = {};
        }
        sap.n.Functions.showAlert = function(){
            alert("hello");
        }
    }
}

 In app A you need to ensure, that app B is loaded:

        AppCache.Load(appB, {
            load: "init"
        });

 

And then you can call the function of app B in App A:

sap.n.Functions.showAlert();

 

Best regards,

Fabian


Hi Fabian


We already have a solution for this, but I see that we have not documented how this approach should be. Our solution is based on a Global Sync App, that other Apps subscribe back to the Sync App and you can actually trigger the sync en each of the subscribers. 


If you like we can setup a websession and I can show how we achieved it. Will that work for you ?


Regards

Ole Andre 


2 people like this

Hi Ole Andre!


That would be just perfect! At the beginning of next week?


Regards,

Fabian

Hi Fabian


That would be perfect. 


Please email me on: ole-andre.haugen@neptune-software.com and we can find the best time for the session.


Regards

Ole Andre 

HI Ole  Andre,
We would like to know how to perform this kind of call.
May you share with us how to call a method owned by the app B from another app A?  


Kind Regards

Answer

Hi Micael,


you can do something like this:


Register your Method in app B to the "sap.n." namespace. ( Pre-condition: Apps need to run within the launchpad)    

if (sap.n) {
    sap.n.Shell.attachBeforeDisplay(function() {

        if (!sap.n.Functions){
               sap.n.Functions = {};
        }
        sap.n.Functions.showAlert = function(){
            alert("hello");
        }
    }
}

 In app A you need to ensure, that app B is loaded:

        AppCache.Load(appB, {
            load: "init"
        });

 

And then you can call the function of app B in App A:

sap.n.Functions.showAlert();

 

Best regards,

Fabian

Login or Signup to post a comment