我只是想知道是否有人知道这些对象是否可以序列化以获得收益或恢复。
NetSuite文档声明以下内容是可序列化的(因此在收益期间可恢复):
All JavaScript native types
nlobjConfiguration
nlobjContext
nlobjError
nlobjFile (files up to 5MB in size)
nlobjRecord
nlobjSubrecord
nlobjSearchColumn
nlobjSearchFilter
nlobjSearchResult
nlobjSearchResultCell
all 3rd party XML Library objects
我发现很奇怪,这个列表中都没有列出。
答案 0 :(得分:2)
nlobjSearch肯定不习惯,我认为结果集也不是。
我通常最终将我的搜索包装在函数中并返回一个值数组以避免可序列化的异常。
e.g。
function batchStatements(){
var statementCusts = (function(){
var allowResend = 'T' == nlapiGetContext().getSetting('SCRIPT', 'custscript_kotn_statement_resend');
var filters = [
sf('balance', null, 'greaterthanorequalto', 35), // over the threshhold
sf('emailtransactions', null, 'is','T'),
sf('custentity_kotn_suppress_statements', null, 'is', 'F')
];
if(!allowResend){
var resendCutoffDays = parseInt(nlapiGetContext().getSetting('SCRIPT', 'custscript_kotn_resend_limit'),10) || 14;// 14 days allows bi-montly batches if desired.
var resendCutoff = new Date(new Date().getTime() - resendCutoffDays * 24 * 3600 * 1000);
nlapiLogExecution("DEBUG", "limit statements since "+ resendCutoff.toISOString());
filters.push(sf('custentity_kotn_last_statement', null, 'notafter', nlapiDateToString(resendCutoff)));
}
var srch = nlapiCreateSearch('customer',
filters,
[
sc('entityid'),
sc('custentity_kotn_billing_email'),
sc('email'),
sc('subsidiary')
]);
var custs = [];
var accum = function(res){
custs.push({
id:res.getId(),
billingEmail: res.getValue('custentity_kotn_billing_email'),
email:res.getValue('email'),
name:res.getValue('entityid'),
subsidiary:res.getValue('subsidiary')
});
return true;
}
srch.runSearch().forEachResult(accum);
return custs;
})();
var testEnt = {};
simpleBatch(statementCusts, function(cust){
nlapiLogExecution("AUDIT", "Sending Statement for "+ cust.name);
var entityComms = entityPreferences.getCustEntity(cust.id);
var pdfFile = generateStatement(cust.id);
var emailFile = kotnMergeTemplate(entityComms.statementEmailTemplate, 'customer', cust.id);
nlapiSendEmail(entityComms.emailFromEmp, cust.billingEmail || cust.email || entityComms.actionEmp, emailFile.getName(), emailFile.getValue(), null, null, {entity:cust.id}, pdfFile, true);
});
}
simpleBatch来自https://github.com/BKnights/KotN-Netsuite 它通过跟踪函数的最大治理并在需要时屈服来处理治理管理。