Fiori - Cross Application Navigation

二次信任 提交于 2019-11-27 16:59:58

问题


I want to navigate between the applications in launchpad. I have found with lot of searching that, through CrossApplicationNavigation in ushell is the way. Here is the link to documentation (SAPUI5 SDK - Demo Kit)

Each application in launchpad has 'semantic object' and 'action' for further navigation.

I have followed documentation and written following piece of code to create CrossApplicaionNavigation service.

var fgetService =sap.ushell && sap.ushell.Container && sap.ushell.Container.getService;
this.oCrossAppNavigator = fgetService && fgetService("CrossApplicationNavigation");

Just to make sure that oCrossAppNavigator service is properly initiate wrote following code.

var hashForApp =  this.oCrossAppNavigator.hrefForExternal({
            rget : { semanticObject : "SalesOrder",action : "create" }
});
console.log("Hash for the application: " + hashForApp);

console Output: #SalesOrder-create

So knowing the service works, I wrote following code to navigate to the "SalesOrder" application and to the "create" action.

this.oCrossAppNavigator.toExternal({
    target : { semanticObject : "SalesOrder",action : "create" }
});

Here is the my issue. Above statement neither goes to the SalesOrder application nor prints any error in the console. It supposed to update the URL with the above hash code and go to that application.

Note: Manual changing of URL with the above hash code correctly going to SalesOrder application.

Thanks in advance,

vagley


回答1:


Are you trying to run this locally? Because if so, then it doesn't work as expected, unless both the applications (the app where you've added the cross app code and the 'SalesOrder-create' app) are running in the "local sandbox"

However if you have tried to run this piece of code in an app installed in a Fiori Launchpad on an SAP dev/test system, which also has the 'SalesOrder-create' app in the same launchpad, then it should work just fine.

Also use the following way to check if the cross-app service is working, because it looks like your code always outputs #SalesOrder-create

if (sap.ushell && sap.ushell.Container && sap.ushell.Container.getService)
{
  var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");

   oCrossAppNavigator.toExternal({
                      target: { semanticObject : "SalesOrder", action: "create" },   //the app you're navigating to 
                        // params : { param1:data, param2:data}
                     }); 
  }
else
{
     jQuery.sap.log.info("Cannot Navigate - Application Running Standalone");
 }
}


来源:https://stackoverflow.com/questions/27844715/fiori-cross-application-navigation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!