Service Variable results
Service variable result sets should always be obtained in the onResults, onSuccess or other service variable event. Using service variable events ensures:- The service call has returned.
- Errors returned from the service call are handled
- The result set is available.
- Create an HQL query, say getCustomers
- Create a Service Variable that invokes the query, say serviceVar1
- Drag a button on the palette and bind the onClick event for that button to serviceVar1. This will have the same effect as calling serviceVar1.update() in Javascript and will cause the HQL query to be executed
- Invoke a Javascript function from the onResult event for serviceVar1. This will call a Javascript function when the HQL query returns its results.
- The result of the HQL query will be in the inSender parameter of the onResult function.
- Use the inSender.getCount() function to fine out how many rows were returned by the HQL query
- Use the inSender.getItem(i) to return the ith row of the query (first row is 0)
- Use row.data.columnName to return a particular column in a row.
serviceVariable1Result: function(inSender, inData) {
try {
console.log(inSender.getData());
var i;
var rtnString = '';
var numRows = inSender.getCount();
console.log('Number of rows returned from HQL query = '+numRows);
if (numRows > 0) {
for (i=0; i < numRows; i++) {
var aRow = inSender.getItem(0);
rtnString += 'Row '+(i+1)+' '+aRow.data.contactlastname+'\n';
alert('Contact is '+aRow.data.contactlastname);
}
}
this.largeTextArea1.setDataValue(rtnString);
} catch(e) {
console.error('ERROR IN serviceVariable1Result: ' + e);
}liveVariable1Result: function(inSender, inData) {
console.log(inSender.getData());
debugger;
}
on 12/05/2010 at 08:38


