Please refer to the source code of this page for boilerplates (F12 for console).

1. Wiring up



Notes:
Standalone (no external libs required).
It is recommended to add local fallback version of the library if you use it in production (click "download" on the right).
We bear no responsibility for possible reachability interruption of directly linked components, they are useful to cold start your project and set up testing.

For basic APIs concerning ECS/Core communication with SAP go to theobald.ecs.micro (tEcs)


2.1 Sharepoint Admin APIs

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);
});

4. Changelog

5.1 Updated theobald.ecs.micro to include new combobox API
5.0 Updated to theobald.ecs.micro 5
4.14 Fixed session instance not being assign to parameters
4.13 Updated connection functions to use session when possible
4.12 Added sessions variables with APIs
4.11 Improved string operations (trim/pad). Added function sp.setFullscreenMode() - use "false" for quit fullscreen mode
4.10 Implemented working with ECSCore settings through a SharePoint list (saving/reading), setting "useSharepointSettings"
4.9 Implemented SOAP Envelope builder for SOAP Queries in SharePoint for Services created with Web Service Designer
4.8 Parameters in the Url, connection.ecs setting of type object "urlParameters", fixed TestConnection()
4.7 SharePoint APIs: connection.ecs setting "useSharepointApiKey" for using persistent SharePoint per App Settings
4.6 APIs for persistent SharePoint per App Settings