如何从NetSuite中的nlapiSearchRecord中更新custbody值。

huangapple go评论62阅读模式
英文:

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);
}

搜索没有问题,但当我尝试使用nlapiSetFieldValuesetFieldValue进行更新时,我从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);
}

huangapple
  • 本文由 发表于 2023年2月24日 06:24:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定