// Client script to call the UI script either for backend or workspaces g_scratchpad.vfConfirm = function(message, callback){ // This is the backend if (typeof GlideModal !== 'undefined') { vfConfirm(message, function(result) { callback(result); }); } else { // This is for the workspace g_ui_scripts.getUIScript('vfConfirm').then(function(uiScript) { uiScript().vfConfirm(message, g_modal, function(result) { callback(result); }); }); } }; // UI Script for backend. Type = Desktop and Global=Ticked function vfConfirm(message, callback) { var dialog = new GlideModal('glide_modal_confirm', true, 300); dialog.setTitle(new GwtMessage().getMessage('Confirmation')); dialog.setPreference('body', new GwtMessage().format(message)); dialog.setPreference('focusTrap', true); dialog.setPreference('onPromptCancel', function() { callback(false); }); dialog.setPreference('onPromptComplete', function() { callback(true); }); dialog.render(); } // UI Script workspace. Mobile/Service Portal. (function() { "use strict"; return { vfConfirm : function(message, g_modal, callback) { g_modal.confirm('Confirmation', message, "", { "cancelTitle": "No", "confirmTitle": "Yes" }).then( function onSuccess() { callback(true); }, function onReject() { callback(false); } ); }, type: "vfConfirm" }; });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter