Use javascript variable for settings of JSDO services

Posted by wardcouckecac on 26-Apr-2013 12:52

Is it possible to use a variable for the settings of a JSDO service in the mobile app builder? So you have the serviceURI and catalogURI where you have to hardcode the URI's. Is it possible to put a variable here of do it programatically?

Because if you have 10 services, and something in the servername/serverport/appname changes then you have to change the URI's in 20 places. Same if you add or replace services.

All Replies

Posted by Peter Judge on 26-Apr-2013 13:38

Unfortunately this is not supported today. I would suggest contacting Tech Support with this issue.

You may be able to workaround the issue by adding your own load-from-file function in the home screen's onload event handler.

You might do something like the below.

Servicesettings.json

[

{"name": "SecurityTokenService_SecurityTokenService_Settings",

"properties":{

"catalogURL": "http://nbbedpjudge1:8980/SecurityTokenService/static/mobile/SecurityTokenService.json",

"RESTapplicationURL": "http://nbbedpjudge1:8980/SecurityTokenService",

"resourceName": "SecurityTokenService"

}

},

{"name": "VehicleOrderService_ShoppingCartService_Settings",

"properties": {

"catalogURL": "http://nbbedpjudge1:8980/VehicleOrderService/static/mobile/VehicleOrderService.json",

"RESTapplicationURL": "http://nbbedpjudge1:8980/VehicleOrderService",

"resourceName": "ShoppingCartService"

}

}

]

The code below will most likely need tweaking for your purposes.

$.getJSON('servicesettings.json', function(response){

for ( var i = 0; i

switch (response.name) {

when " SecurityTokenService_SecurityTokenService_Settings":

SecurityTokenService_SecurityTokenService_Settings = response.properties;

// or just a single property?

SecurityTokenService_SecurityTokenService_Settings.catalogURL = response.properties.catalogURL;

Break;

//etc

Default:

}

});

-- peter

This thread is closed