在netsuite中点击自定义按钮可以显示记录的编辑页面吗?

It is possible to show the edit page of the record by clicking the custom button in netsuite?

我想通过单击自定义按钮而不是 "standard edit button"

来显示记录的编辑页面

我的代码:

Script Version: Suite Script 2.0
User Event Script:
    function beforeLoad(context) {

        log.debug('Test', 'Before Load Event Initiated');
        var frm = context.form;
        frm.clientScriptFileId = 2250;

        //Values from System/ScriptContext
        var record = context.newRecord;
        if (context.type == context.UserEventType.VIEW) {
            frm.addButton({
                id: 'custpage_cust_edit_btn',
                label: 'Deactivate Record',
                functionName: 'customRecordEditMode(' + record.id + ')'
            });
        }

    }

Client Script:

    function customRecordEditMode(recordID) {
        debugger;
        try {
            window.location.href = "https://system.sandbox.netsuite.com/app/common/custom/custrecordentry.nl?rectype=194&id=" + recordID + "&e=T";
        } catch (exception) {
            alert("Error:", exception.message);
        }
    }

错误消息:

我收到以下错误消息:

但是记录的url和我们点击标准的"Edit"按钮是一样的。 (i,e) rectype=194&id=237&e=T

提前致谢

我不太确定为什么使用原始 URL 会出现此错误,但您是否尝试过使用 N/url 模块而不是使用原始 URL ?

require(['N/url', 'N/record'], function(url, r) {
    var output = url.resolveRecord({
        recordType: r.Type.SALES_ORDER,
        recordId: 6,
        isEditMode: true
    });
});

或者更好的可能是 N/redirect 模块:

require(['N/redirect', 'N/record'], function(redirect, r) {
    redirect.toRecord({
        "type": r.Type.TASK,
        "id": 6,
        "isEditMode": true
    });
});