如何通过 Netsuite 中的临时 CS 通过 prompt() 设置字段的值?

How to setValue of a field by prompt() through adhoc CS in Netsuite?

我在采购订单中通过 UE 脚本创建了一个按钮。点击 alert/prompt 将让用户编写文本,并在提示框中点击确定,该文本将保存在自定义字段中。 我试着做 submitFields 但它什么也没做。谁能帮我解决这个问题?

用户事件代码:

        context.form.addButton({
            id: 'custpage_reject',
            label: 'Reject With Reason',
            functionName: 'rejectButton()'
        })
        context.form.clientScriptModulePath = 'SuiteScripts/mx_rejectionReason_cs.js';

客户端脚本函数:

function rejectButton() {
    rejectReasonValue = window.prompt("Reason for Rejection ?");
    console.log('prompt:', rejectReasonValue)

    nsCurrentRecord.submitFields({
        type: recType,
        id: recId,
        values: {
          custbody_reasonof_rejection: rejectReasonValue,
        },
        options: {
          enableSourcing: true,
          ignoreMandatoryFields: true
        }
      });
}

我认为您的 submitFields 不适用于当前加载的记录。

尝试像这样设置当前记录的字段值:

currentRecord.setValue('custbody_reasonof_rejection', rejectReasonValue);

希望这对你有用!