Im using SweetAlert2 in the saveRecord on a client...
# suitescript
e
Im using SweetAlert2 in the saveRecord on a client script running on a Sales Order.... It shows a pop up with OK or Cancel buttons if the Billing Address is missing certain fields. But whether I press OK or Cancel, the record does not save. Anyone see my issue? (Code in reply)
Copy code
function warnMissingBillingInfo() {
    try {
        var billingSubrecord = orderConfirmation.getSubrecord('billingaddress')
        var billCity = billingSubrecord.getValue('city');
        var billState = billingSubrecord.getValue('state');
        var billZip = billingSubrecord.getValue('zip');

        if (!billCity || !billState || !billZip) {
            Swal.fire({
                title: 'Do you want to save the changes?',
                html: `The bill to address is missing either the City, State, or Zip Code. <br><br>Press Cancel to make changes. Press OK to continue.`,
                showDenyButton: true,
                denyButtonText: `Cancel`,
            }).then((result) => {
                console.log('result', result);
                if (result.isConfirmed) {
                    console.log('should be true');
                    return true;
                } else if (result.isDenied) {
                    console.log('should be false');
                    return false;
                }
            });
        } else {
            return true;
        }
    } catch (error) {
        log.error('error from warnMissingBillingInfo', error);
        library.sendErrorEmail(error, 'CSOC_MAIN warnMissingBillingInfo');
    }
}
The console logs both show correctly based on which button you press
b
asnychronous code is not compatible with saveRecord
it requires a synchronous return
e
So I'll likely need to go back to a confirm() then? That's what I was using and it worked fine
Just wanted to make it prettier...
b
making it prettier will cost you dom manipulations
e
Fair enough - bringing back the confirm()