英文:
How to update a custbody value in netsuite from a nlapiSearchRecord
问题
我尝试从账单中更新一个custbody字段。脚本是一个Web钩子,当支付成功时接收信息,所以当通过Web钩子发送invoice_id时,系统会搜索发票信息。在那一点上,我需要将一个字段更新为"已支付"。我的代码如下:
var netsuiteInformation = nlapiSearchRecord('vendorbill', null, filters, columns);
markInvoiceAsPaid(netsuiteInformation, foo);
function markInvoiceAsPaid(infoDocNetsuite, data) {
var status = infoDocNetsuite[0].getValue('custbody_payment_status');
infoDocNetsuite[0].nlapiSetFieldValue('custbody_payment_status', 3);
infoDocNetsuite[0].nlapiSetFieldValue('custbody_reject_reason', data.reasonDescription);
}
搜索没有问题,但当我尝试使用nlapiSetFieldValue
或setFieldValue
进行更新时,我从netsuite得到一个错误,如下所示:
TypeError: Cannot find function nlapiSetFieldValue in object nlobjSearchResult. (cancelPaymentWebhook.js$4053079#30)
因此,我不知道如何进行更新。你知道如何做吗?
谢谢!
英文:
I'm trying to update a custbody field from a bill. The script is a webhook that receives information when a payment was successfully, so when the invoice_id is sent via the webhook, the system search for the invoice information. At that point is when i need to update a field to set it as "Paid". My code is like the following;
var netsuiteInformation = nlapiSearchRecord('vendorbill', null, filters, columns);
markInvoiceAsPaid(netsuiteInformation, foo)
function markInvoiceAsPaid(infoDocNetsuite, data) {
var status = infoDocNetsuite[0].getValue('custbody_payment_status');
infoDocNetsuite[0].nlapiSetFieldValue('custbody_payment_status', 3);
infoDocNetsuite[0].nlapiSetFieldValue('custbody_reject_reason', data.reasonDescription);
}
The search is being performed without problems, but when i try to do an update using nlapiSetFieldValue
or setFieldValue
im getting an error from netsuite like this one:
TypeError: Cannot find function nlapiSetFieldValue in object nlobjSearchResult. (cancelPaymentWebhook.js$4053079#30)
So i dont know how to make the update. Do you know how to do it?
Thank you!
答案1
得分: 1
nlapiSetFieldValue 不是搜索结果对象的成员。如果这是客户端脚本,您可以直接调用该函数,或者如果这是用户事件或其他情况,您需要使用 nlapiLoadRecord(type, id)
加载记录,然后使用 recordObj.setFieldValue(fieldId, value)
进行更新。
var netsuiteInformation = nlapiSearchRecord('vendorbill', null, filters, columns);
markInvoiceAsPaid(netsuiteInformation, foo)
function markInvoiceAsPaid(infoDocNetsuite, data) {
var status = infoDocNetsuite[0].getValue('custbody_payment_status');
nlapiSetFieldValue('custbody_payment_status', 3);
nlapiSetFieldValue('custbody_reject_reason', data.reasonDescription);
}
英文:
nlapiSetFieldValue isn't a member of the search result object. You can just call the function directly if this is a client script or if it's a user event or otherwise you will need to load a record using nlapiLoadRecord(type, id)
and update it with recordObj.setFieldValue(fieldId, value)
var netsuiteInformation = nlapiSearchRecord('vendorbill', null, filters, columns);
markInvoiceAsPaid(netsuiteInformation, foo)
function markInvoiceAsPaid(infoDocNetsuite, data) {
var status = infoDocNetsuite[0].getValue('custbody_payment_status');
nlapiSetFieldValue('custbody_payment_status', 3);
nlapiSetFieldValue('custbody_reject_reason', data.reasonDescription);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论