Client need to accept the terms and conditions to enable the save of a record.
NetSuite uses the ExtJS library for a variety of purposes including showing popup windows for alerts and confirmations. We can make use of this to tailor this popup window for our own uses cases which would otherwise couldn’t be met using the standard ‘N/ui/dialog Module’
Note : We are using the ExtJS library which NetSuite used for building their own popup/modal/dialog purpose. If NetSuite decides to upgrade this library or change this to another library, it may break the existing scripts if we use the ExtJS library directly.
function saveRecord(scriptContext) {
try {
var rec = scriptContext.currentRecord;
let message= `
<div>
<h3>Terms & Conditions for Orders</h3>
<p>
1. Order Acceptance: By placing an order through our Customer Center, you agree to the following terms and conditions.
All orders are subject to acceptance by [Your Company Name].
</p>
<p>
2. Pricing and Payment: All prices listed on the Customer Center are in [Currency]. Payment must be made in full
at the time of placing the order. Prices and availability are subject to change without notice.
</p>
<p>
3. Shipping and Delivery: Shipping costs and estimated delivery times will be provided during the checkout process.
Please note that delivery times are approximate and may vary.
</p>
<!-- ... Other terms ... -->
</div>
`
function showPopupWindow() {
// Create the terms and conditions text
var termsAndConditionsText = message;
Ext.MessageBox.buttonText = {
yes: 'I have read and accept the terms and service',
no: 'Cancel'
};
// Display the confirmation message using Ext.MessageBox.confirm
Ext.MessageBox.confirm('Terms and Conditions', termsAndConditionsText, function(buttonId) {
if (buttonId === 'yes') {
// User clicked 'Accept'
console.log('User accepted the terms');
// popupWindow.close();
finalResult = true;
getNLMultiButtonByName('multibutton_submitter').onMainButtonClick(this);
//('multibutton_submitter').onMainButtonClick(this);
} else {
// User clicked 'No' or closed the message
console.log('User canceled');
// popupWindow.close();
return false;
}
});
}
// Call the function to show the confirmation message
showPopupWindow();
} catch (e) {
console.log("Error @ saveRecord", e);
}
}