Hi
I am trying to follow the example in SuiteAnswers id: 93513 though am finding the user event is failing to trigger the client script.
The ids are correct in both scripts
The userevent script
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(["N/record", "N/url"], function (url, record) {
/**
* @param {UserEventContext.beforeLoad} context
*/
function beforeLoad(context) {
if (
context.type == context.UserEventType.EDIT ||
context.type == context.UserEventType.VIEW
) {
var form = context.form;
//the internal id of the client script file in the filing cabinet
form.clientScriptFileId = 9198;
form.addButton({
id: "custpage_add_note",
label: "Add Note",
//onclick_callforSuitelet without the brackets has also been used
functionName: "onclick_callforSuitelet()",
});
}
}
return {
beforeLoad: beforeLoad,
};
});
The Client script
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(["N/record", "N/url"], function (record, url) {
/**
* @param {ClientScriptContext.pageInit} context
*/
function pageInit() {}
function onclick_callforSuitelet() {
var record = context.currentRecord;
var recordId = record.id;
var recordType = record.type;
log.debug("recId", recordId);
log.debug("recType", recordType);
//this is the script id on the script record for the suitelet (not the deployment)
var suiteletURL = url.resolveScript({
scriptId: "customscript_suitelet_notes",
//this is the id from the deployment record for the suitelet
deploymentId: "customdeploy_suitelet_notes",
params: { recordId: recordId, recordType: recordType },
});
document.location = suiteletURL;
log.debug("suiteletURL", suiteletURL);
}
return {
onclick_callforSuitelet: onclick_callforSuitelet,
pageInit: pageInit,
};
});
I don;t receive an error though clicking on the button on the record does not do anything either.
Where am I going wrong in the scripts?