1

我想通过单击自定义按钮而不是“标准编辑按钮”来显示记录的编辑页面

我的代码:

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 与我们单击标准的“​​编辑”按钮时相同。(i,e) rectype=194&id=237&e=T

提前致谢

4

1 回答 1

2

我不确定为什么原始 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
    });
});
于 2016-09-21T16:02:54.633 回答