The component id of the current view instance.
The configuration of the component to render.
The rendered HTML of the view.
The configuration of the view to render.
The viewFields of the view.
Executes a method.
// Example when executing a method with no input fields.
CSL.rest.executeMethod('Product', 'Get All Products', 'Training SQL')
.then(methodResults => {
// `methodResults` is an array because you are able to send more than one context record.
methodResults.forEach(methodResult => {
if (methodResult.hasError) {
alert(methodResult.error);
} else {
methodResult.results.forEach(result => {
// A single record in a method execution.
console.log(result);
});
}
});
}).catch(err => {
// Network related error or any 500 error response code from the API.
alert(err);
});
// Example where the page size is set. Only items 1 to 25 are retrieved.
const queryOptions = {
FirstItem: 1,
PageSize: 25
}
CSL.rest.executeMethod('Product', 'Get All Products', 'Training SQL', null, queryOptions)
.then(methodResults => {
console.log(methodResults[0].results.length); // output 25
})
.catch(err => { console.error(err); });
ApiError Any network related error or any 500 error response code from the API.
The name of the object.
The name of the method.
The name of the profile.
The context records that will be used as input for the method.
Optional
queryOptions: QueryOptionsOptions for altering the query results. Limit results, skip items,...
Get filter values of a view.
// Filter based on product names that contain 'a' and the stock is meer dan 100.
const expression = {
filters: [{
field: 'productName',
operator: 'ct',
value: 'a'
}, {
field: 'productStock',
operator: 'gt',
value: '100'
}],
logic: 'and'
};
const context = [{productName: 'a'}];
CSL.rest.getFilterValues('Product', 'Get All Products', 'productName', context, { Expression: expression }).then((results) => {
let stocks = results.map(option => option.data['productStock']);
});
The name of the object.
The name of the view.
The name of the field you want to filter.
The records to use as context.
The options to send with the call.
Executes the prepare call for a view.
CSL.rest.prepareView('Product', 'Get All Products', [{productName: 'ABC'}]).then((result) => {
// Prepare result
});
The name of the object.
The name of the view.
The context records to use as context in the call.
Validates if the values exist.
const valuesToValidate = [
{ fieldName: 'productName', values: ['AB', 'CD'] },
{ fieldName: 'productCategoryId', values: [7] }
];
const customContext = [ {userName: 'John'} ]
CSL.rest.validateValue('Product', 'Insert Product', valuesToValidate, customContext).then((results) => {
// Check if all results are valid.
const allValid = (results.find((r) => r.isValid) !== undefined);
});
The name of the object.
The name of the view.
The values that will be validated.
The context to send with the call.
Generated using TypeDoc
This class contains methods for calling the Generic REST Service with custom scripting.