1

I want to show the edit page of the record by clicking the custom button instead of the "standard edit button"

My Code:

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

ERROR Message:

I'm Getting the Following Error Message:

enter image description here

but the url of the record is same as in when we click the standard "Edit" Button. (i,e) rectype=194&id=237&e=T

thanks in advance

Deepan Murugan
  • 721
  • 2
  • 19
  • 41
  • Your code appears to be missing a lot of the required 2.0 pieces. But, best I can tell, from the docs, the addButton piece is only available to suitelets. It is part of the N/ui/serverWidget Module. Sorry I could not help out more. – w3bguy Sep 21 '16 at 12:58

1 Answers1

2

I'm not exactly sure why you would be getting this error with the raw URL, but instead of using the raw URL, have you tried utilizing the N/url module?

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

or perhaps even better would be the N/redirect module:

require(['N/redirect', 'N/record'], function(redirect, r) {
    redirect.toRecord({
        "type": r.Type.TASK,
        "id": 6,
        "isEditMode": true
    });
});
erictgrubaugh
  • 8,519
  • 1
  • 20
  • 28