This repository contains a JavaScript library for consuming SData.
- Install nodejs
- Install gruntjs via command line:
npm install -g grunt-cli
- Run
npm install
in the SDataJavaScriptClientLib folder root - Run
grunt test
in the SDataJavaScriptClientLib folder root
-
Windows
-
The Java Runtime (JRE)
-
The environment variable,
JAVA_HOME
, pointing to the JRE base path, eg:c:\Program Files (x86)\Java\jre6
-
Open a command prompt and execute the following from the root repository folder, eg:
build\release.cmd
-
The deployed product will be in a
deploy
folder in the root repository folder.
var service = new Sage.SData.Client.SDataService({
url: 'http://localhost/sdata/slx/dynamic/-/',
userName: 'admin',
password: '',
json: true //if your SData provider supports JSON
});
var request = new Sage.SData.Client.SDataSingleResourceRequest(service)
.setResourceKind('contacts')
.setResourceSelector("'CGHEA0000001'");
request.read({
success: function(entry) { console.log(entry); }
});
var request = new Sage.SData.Client.SDataResourceCollectionRequest(service)
.setResourceKind('contacts')
.setCount(5)
.setStartIndex(6); // 1 based, not 0 based (per spec)
request.read({
success: function(feed) { console.log(feed); }
});
var request = new Sage.SData.Client.SDataResourcePropertyRequest(service)
.setResourceKind('accounts')
.setResourceSelector("'AGHEA0002669'")
.setResourceProperty('Contacts')
// use `readFeed` since we are targeting a collection property
request.readFeed({
success: function(feed) { console.log(feed); }
});
var batch = new Sage.SData.Client.SDataBatchRequest(service)
.setResourceKind('accounts')
.using(function() {
new Sage.SData.Client.SDataSingleResourceRequest(service)
.setResourceKind('accounts')
.setResourceSelector("'AGHEA0002669'")
.read();
new Sage.SData.Client.SDataSingleResourceRequest(service)
.setResourceKind('accounts')
.setResourceSelector("'AA2EK0013031'")
.read();
});
batch.commit({
success: function(feed) { console.log(feed); }
});