getAllVariants: function(fnCallBack) { var oPersonalizationVariantSet= {}, aExistingVariants =[], aVariantKeysAndNames =[]; //get the personalization service of shell this._oPersonalizationService = sap.ushell.Container.getService('Personalization'); this._oPersonalizationContainer = this._oPersonalizationService.getPersonalizationContainer("MyVariantContainer"); this._oPersonalizationContainer.fail(function() { // call back function in case of fail fnCallBack(aExistingVariants); }); this._oPersonalizationContainer.done(function(oPersonalizationContainer) { // check if the current variant set exists, If not, add the new variant set to the container if (!(oPersonalizationContainer.containsVariantSet('MyApplicationVariants'))) { oPersonalizationContainer.addVariantSet('MyApplicationVariants'); } // get the variant set oPersonalizationVariantSet = oPersonalizationContainer.getVariantSet('MyApplicationVariants'); aVariantKeysAndNames = oPersonalizationVariantSet.getVariantNamesAndKeys(); for(var key in aVariantKeysAndNames){ if (aVariantKeysAndNames.hasOwnProperty(key)) { var oVariantItemObject = {}; oVariantItemObject.VariantKey = aVariantKeysAndNames[key]; oVariantItemObject.VariantName = key; aExistingVariants.push(oVariantItemObject); } } fnCallBack(aExistingVariants); }.bind(this)); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter