Skip to Content

SAPUI5 - Accessing current sub-account from the controller.

I'm accessing a URI from my controller which at the moment is hardcoded to my current SAP Cloud Platform Sub-Account.

window.open("https://rsaactionplan-%28subaccount%29.dispatcher.hana.ondemand.com/index.html#/actionplan/">rsaactionplan-(subaccount).dispatcher.hana.ondemand.com/index.html#/actionplan/" + oBindingContext.JobId, "_system");

Rather than hard-code it, how can I access the current sub-account ID so I can dynamically setup the sub-account in the SAPUI5 controller?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 06 at 01:39 PM

    Solution for Moble + Web app..

    Following ANY oData call.....

     var uriStr; 
        if (typeof sap.hybrid !== 'undefined') {
            uriStr = oUserData.__metadata.uri;
        }
        else{
            uriStr = window.location.href;
        }
        var split1 = uriStr.split("-");  // split by - 
        var secondSubString = split1[1]; // all characters AFTER the first -
        var split2 = secondSubString.split(".");  // split by . 
        self.subAccount = split2[0];  // all characters BEFORE the first .
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 05 at 07:27 PM

    Hi Adam,

    take a look at HashChanger.

    It seems to me, that you just want to change the Hash.

    If you want to have more control over the whole url, you can get it with window.location.href.

    Best regards,

    Christian.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Christian. This only works if called from a Web App...

      When it's called from our Hybrid App (Still SAPUI5), windows.location.href is "file:/android_asset/www/html".

      No sub-account is returned.