Confirmation Dialog Box using N/ui/dialog Module

Trigger a function in Client-side script in View mode by a Button added using User Event Script and when pressing the button on the form, it will create a confirmation dialog with OK and Cancel buttons

function onButtonClick(scriptContext) {‌

    console.log('1. Made it to client script');

    dialog.confirm({‌
        title: 'Warning!',
        message: 'There are subscribers in this order already, are you sure you want to proceed?'
    }).then(success).catch(failure);

    console.log('2. onButtonClick function ran');
}

function success(result) {‌

    alert('Success with value ' + result);

    if (result === false) {‌
        return failure();
    }else{‌
        console.log('3. Success function ran');  // or further code logic to add Subscribers to the Sales Order Record
    }
}

function failure(reason) {‌
    alert('Failure: ' + reason);
    console.log('User terminated request')

    return;
}

Leave a comment

Your email address will not be published. Required fields are marked *