Imran Hasan
11/10/2024, 5:30 AMCeligo AI
11/10/2024, 5:30 AMAI generated answer (using internal Slack threads):To create a save button in NetSuite, you can use the
Form.addSubmitButton
method which will create a button that posts to your Suitelet. Here is an example:
javascript
form.addSubmitButton('Save');
If you want to create a custom "Save & ____" button, you can add a button on beforeLoad which triggers a client script. The client script sets the value of a hidden checkbox field to "true," then triggers the click()
method on the Save button. In the afterSubmit, if that field value is true, you perform your conditional afterSubmit action and set the field to false.
javascript
form.addButton({
id: 'custpage_mybutton',
label: 'Save & ____',
functionName: 'myFunction'
});
In your client script:
javascript
function myFunction() {
var record = currentRecord.get();
record.setValue('custpage_mycheckbox', true);
document.getElementById('btn_multibutton_submitter').click();
}
In your afterSubmit user event script:
javascript
function afterSubmit(context) {
var record = context.newRecord;
if (record.getValue('custpage_mycheckbox')) {
// Perform your action
record.setValue('custpage_mycheckbox', false);
}
}
If you need to identify which button a user has clicked in the form, you can check for the submitter value var buttonValue = context.request.parameters.submitter;
. However, this is only applicable for Suitelet pages. For user event or client scripts, there isn't a direct way to identify which button was clicked.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
11/10/2024, 5:30 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.860895336
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852768898
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839546442
Celigo AI
11/10/2024, 5:30 AM