问题
I'm running into problems getting aging information for a customer record via a Restlet. Specficially I'm looking to get the aging, aging1, aging2, aging3, and aging4 fields from the Customer form for a given customer.
In the UI those values are found on the Customer form under the "Financial" section and look something like:
Current 1-30 Days 31-60 Days 61-90 Days Over 90 Days
1200.00 800.00 720.37 423.23 42.00
My Restlet code looks something like this:
…
cols[6] = new nlobjSearchColumn('aging');
var result = nlapiSearchRecord(data.record_type, null, filter, cols);
return result;
It works great with other fields such as "balance", but when I include the "aging" field and run my GET I see this error:
"error": {
"code": "SSS_INVALID_SRCH_COL",
"message": "An nlobjSearchColumn contains an invalid column, or is not in proper syntax: aging."
}
Clearly I'm not doing something right. Are those fields special in some way? How do I retrieve those values?
回答1:
Easy enough to add in a suitescript context. e.g.
var aging = nlapiSearchRecord('invoice', null, [
new nlobjSearchFilter('daysoverdue', null, 'greaterthan', 0),
new nlobjSearchFilter('mainline', null, 'is', 'T'),
new nlobjSearchFilter('amountremaining', null, 'greaterthan', 0)
//for your RESTLet maybe you need this: , new nlobjSearchFilter('entity', null, 'is', data.customer_id)
], [
new nlobjSearchColumn('entity', null, 'group'),
new nlobjSearchColumn('formulanumeric', null, 'sum').setFormula('case when {daysoverdue} < 31 then {amountremaining} else 0 end'),
new nlobjSearchColumn('formulanumeric', null, 'sum').setFormula('case when {daysoverdue} between 31 and 60 then {amountremaining} else 0 end'),
new nlobjSearchColumn('formulanumeric', null, 'sum').setFormula('case when {daysoverdue} between 61 and 90 then {amountremaining} else 0 end'),
new nlobjSearchColumn('formulanumeric', null, 'sum').setFormula('case when {daysoverdue} > 90 then {amountremaining} else 0 end')
]);
aging.forEach(function (inv) {
var cols = inv.getAllColumns();
console.log(inv.getText('entity', null, 'group') +
' 0-30: ' + inv.getValue(cols[1]) +
' 31-60: ' + inv.getValue(cols[2]) +
' 61-90: ' + inv.getValue(cols[3]) +
' > 90: ' + inv.getValue(cols[4]));
});
回答2:
As far as I recall there is no search column for customers called 'aging'. This is the cause for the Invalid Search column error.
Also those fields might not be exposed either to the searches or suitescript which is why you are getting the error.
回答3:
I actually contacted Netsuite and the previous comments are correct, those fields are not exposed, so I simply can't use them.
There is currently an enhancement request #238854 to expose these fields.
回答4:
Just a followup note on this: After almost three years Netsuite has still not acted on that enhancement request even though it has been voted for 30 times. Also the solution above results in numbers that are usually, but not always, in line with what is displayed by Netsuite.
来源:https://stackoverflow.com/questions/31756717/how-to-get-customer-aging-fields-from-a-netsuite-restlet