2.1.1 Single Setting Setters
Set Settings inside of current SharePoint scope (e.g. App) programmatically (callbacks are optional). Returns deferred object.
theobald.sp.setEcs
ApiKey(apiKey, [callbackOk, callbackError])
theobald.sp.setEcs
Instance(instance, [callbackOk, callbackError])
theobald.sp.setEcs
Url(url, [callbackOk, callbackError])
Examples:
theobald.sp.setEcsApiKey("X121C1D0CC384B5A8F768E9ACC712055");
theobald.sp.setEcsApiKey(
"X121C1D0CC384B5A8F768E9ACC712055",
// callback
function(){ alert('KEY SET!'); },
// error callback
function(sender, args){ alert('KEY FAILED!'); }
);
2.1.2 Cumulative Setters
theobald.sp.initEcsProperties([callbackOk, callbackError])
Creates a SharePoint list in current context (e.g. App). Returns deferred object. Note theobald.sp namespace.
theobald.sp.setEcsProperties(knownProperties, [callbackOk, callbackError])
Returns deferred.
theobald.sp.getEcsProperties(knownProperties, [callbackOk, callbackError])
Returns deferred. CallbackOk gets the retrieved settings. CallbackError gets the KVPs of settings which could not be retrieved with the corresponding errors.
Examples:
theobald.sp.initEcsProperties(
// callback
function(settings){
alert('You can modify settings now from SharePoint GUI (resources).');
},
// error callback
function(errors){
alert('Error occured, do you have a Collaborator (Write) Permissions?');
}
);
theobald.sp.setEcsProperties({
apikey: "X121C1D0CC384B5A8F768E9ACC712055",
instance: "ecc",
url: "https://myecscoreurl.com/ecs/ws"
},
// callback
function(settings){ alert('Settings SET!'); },
// errorback
function(errors){ alert('Saving FAILED!'); }
);
theobald.sp.getEcsProperties().then(
function(properties){
alert('apikey: ' + properties.apikey + ', instance: ' + properties.instance + ', url: ' + properties.url);
}
);
or..
theobald.sp.getEcsProperties(function(properties){
console.log(properties);
});
or..
theobald.sp.getEcsProperties().done(function(properties){
console.info(properties);
});
Now just call functions from another browser or user (within the same App or Webpart):
tEcs.executeXql({
connection: {
ecs: {
useSharepointSettings: true
}
},
data: "SELECT TOP 10 MATNR, MAKTX FROM MAKT WHERE (MATNR LIKE '%%' OR MAKTX LIKE '%%') AND SPRAS = 'EN'",
done: function (data) { console.log(data); },
fail: function (data) { console.error(data); }
});
2.1.3 Meta-settings
tEcs.useSharepointSettings([saveLocalSetting]);
Instructs tEcs to use SharePoint as source of ECSCore Settings in the current context.
Example:
theobald.ready(function(){
// needs to be executed once on SharePoint OnPremise Webpage
tEcs.useSharepointSettings(true);
});
Then after settings the connection parameters Could be directly specified in a function:
tEcs.executeXql({
// no connection parameter needed at all
data: "SELECT TOP 10 MATNR, MAKTX FROM MAKT WHERE (MATNR LIKE '%%' OR MAKTX LIKE '%%') AND SPRAS = 'EN'",
done: function (data) { console.log(data); },
fail: function (data) { console.error(data); }
});
tEcs.askSettingsAndSaveToSharepoint([callbackOk, callbackError])
Use default confirm of your browser to set an APIKey, URL and Instance in SharePoint.
Example:
tEcs.askSettingsAndSaveToSharepoint(function(settings){
console.log('SET OK: %o', settings);
});