Here are the requirements to follow, whenever a plugin has to deal with a custom service:
<es-plugin
name="CustomServiceDemo"
layoutUsage="Job"
smartviewUsage="Desktop,Job"
jsServer="CustomServer.js">
</es-plugin>
if(ESPluginParams.action == "myServerLoad") {
var apiParams = {
'id': 1,
'method': 'job.get',
'params': {
'ID': ESPluginParams.ID
}
};
ESPluginResponse = ESAPI.process(apiParams);
} else if(ESPluginParams.action == "myServerSave") {
var apiParams = {
'id': 2,
'method': 'job.edit',
'params': {
'ID': ESPluginParams.ID,
'description': ESPluginParams.description
}
};
ESPluginResponse = ESAPI.process(apiParams);
}
var JsServerDemo = {
buildComponent: function() {
return '<div>JsServerDemo</div>';
},
serverUpdate: function(response) {
console.log(response);
},
update: function() {
// Nothing done here
},
getLoadModelMessage: function() {
var id = this.getModelProperty('ID');
var params = {
'action': 'myServerLoad',
'ID': id,
};
var request = {params : params};
return request;
},
getStoreModelMessage: function() {
var id = this.getModelProperty('ID');
var params = {
'action': 'myServerSave',
'ID': id,
'description': 'JsServer edited!',
};
var request = {params : params};
return request;
}
};