cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - Accessing current sub-account from the controller.

former_member239819
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

former_member239819
Participant
0 Kudos

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 .

Answers (1)

Answers (1)

former_member306541
Participant
0 Kudos

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.

former_member239819
Participant
0 Kudos

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.