Reputation: 11
I am trying to add a custom button in suitelet 2.0 and I want an action to be performed on click of that button.
I tried doing same like this
form.addButton({
id : 'reset',
label : 'Reset',
functionName: 'setButton'
});
But it doesn't do any action.
Upvotes: 1
Views: 5484
Reputation: 1132
If you're actually looking for a reset button, try the builtin:
form.addResetButton({
label : 'Reset'
});
Otherwise, if you need customization
form.addButton({
id : 'reset',
label : 'Reset',
functionName: 'setButton'
});
form.clientScriptModulePath = 'SuiteScripts/setButton-clientscript.js';
With setButton-clientscript.js
containing your function definition ala:
define(['N/currentRecord'],
function(currentRecord) {
function setButton() {
//your code here
//example: location.reload();
}
return {
setButton: setButton
};
});
Upvotes: 4
Reputation: 3029
You need to include the function in a clientscript file and then attach the clientscript to the form with:
form.clientScriptFileId = 32;
Upvotes: 1