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