javascriptsdkrallyappsdk2

Rally SDK external development Rally.environment undefined


I can't use Rally.environment.getContext() when I develop externally. I need this to get the ProjectOID and the UserOID before the app is launched, so i can't go app.getContext() since it hasn't been created yet.

How do I get the UserOID and ProjectOID from the Rally object while developing externally.

Im using sdk2.0, and I don't want to use hangman variables because the website says they are deprecated.

EDIT: below is an example of a setting for each Project+User combination, which doesn't work locally, and Rally.environment is not set so I can't get if from there.

var SETTINGS_TOKEN = __PROJECT_OID__ + '-' + __USER_OID__;
...
config: {
        defaultSettings: (function(){
            var s = {};
            s['QueryFilter' + SETTINGS_TOKEN] = '';
            return s;
        }())
    },              
    getSettingsFields: function() {
        return [{
            name: 'QueryFilter' + SETTINGS_TOKEN,
            xtype: 'textfield',
            label: 'Query Filter'
        }];
    },

EDIT 2: This seems to work temporarily for running externally (App-Debug tmpl): https://github.com/ssteffl/rally-app-builder/blob/master/templates/ext/App-debug.html.

But the main reason why i wanted get this to work was that PROJECT_OID and Rally.environment are both invalid when not running within the Custom App Iframe, so my jasmine tests fail. I would like to get my tests to pass. I am using this jasmine.tmpl for my tests, and perhaps I have to add the Rally.environment in manually like i did for the App-Debug template: https://github.com/arring/MDO-RallyApps/blob/master/test/jasmine.tmpl


Solution

  • Seems like you found a pretty solid edge case we didn't account for in the SDK- scoping prefs to user + project. I guess I would probably just continue to use the hangman variables since the only other workaround is so much code. They are considered deprecated but they won't be going away any time soon since there are still a ton of SDK 1.x based apps in the catalog that still require them to function correctly. I'd probably just do a little bit of sanity checking with some default values:

    var projectOid = '__PROJECT_OID__';
    var userOid = '__USER_OID__';
    if(projectOid === '__PROJECT' + '_OID__') {
        projectOid = 123456; //well known default for testing
        userOid = 234567; //well known default for testing
    }
    var SETTINGS_TOKEN = projectOid + '-' + userOid;