To use a formula in nlobjSearchColumn objects, one needs to use the setFormula method of the object. Here is a simple example:
function searchWithFormula() {
var columns = new Array();
columns[0] = new nlobjSearchColumn('formulatext');
columns[0].setFormula("CASE WHEN {quantitycommitted}-{quantity}<0 THEN 'Some Items Committed' ELSE 'Fully Committed' END") ;
var results = nlapiSearchRecord('salesorder', null, null, columns);
for(var i in results) {
var result = results[i];
nlapiLogExecution('DEBUG', 'Record Type is: ', result.getRecordType());
nlapiLogExecution('DEBUG', 'Record ID is: ', result.getId());
nlapiLogExecution('DEBUG', 'Commitment Status: ', result.getValue(columns[0]));
}
}
The result of this script is detailed on the screenshot below:
No comments:
Post a Comment