Search code examples
javascripturlsapui5cross-application

How to send an array using CrossAppNavigation?


I have both my apps in the FLP. At present I am sending only limited data so I am able to send it by appending it to URL. I would like to change this and send an array. I tried using AppState but it does not seem to work and I could not find an example with the new UI5 version (1.120.9) Could someone please help me with this? Thank you!

 Container.getServiceAsync("Navigation").then((oCrossAppNavigator) => {
 oCrossAppNavigator.getHref({
 target: { shellHash: 'xyz + plant=$plant' + material + ... }
 }).then((hash) => { if (navigationOption === "newTab") {
 let URLHelper = library.URLHelper;
  URLHelper.redirect(hash, true); }
  else {
oCrossAppNavigator.navigate({
 target: {shellHash: hash}
 });

My current implementation is above.

This is what I tried

sap.ushell.Container.getServiceAsync("CrossApplicationNavigation").then((oCrossAppNav) => {
                const oAppState = oCrossAppNav.createEmptyAppStateAsync(this);
                oAppState.setData(arrayData);
                oAppState.save();
oCrossAppNav.getHrefForAppSpecificHash('xyz&sap-iapp-state=${oAppState.getKey()}')
.then((hash) => {{ if (navigationOption === "newTab") {
                            let URLHelper = library.URLHelper;
                            URLHelper.redirect(hash, true); }
                else {
                    oCrossAppNavigator.navigate({
                                target: {
                                    shellHash: hash
                                }
                            });


Solution

  • Added this

    localStorage.setItem("Data", JSON.stringify(Data));
    

    before Container.getServiceAsync("Navigation").then((oCrossAppNavigator) => {