dialog window in client script - alternative for service portal needed

LG2
Mega Expert

Hi,

we have a client script which opens a new window for some terms and conditions acknowledgement which is not working for the Service Portal.

Ihave found other references which relate to a widget but the ts&cs only need to appear under certain circumstances (which is controlled by a - working - UI script).

here is our script (which runs on all UIs) - can anyone suggest what we need to change please so that it will run on all UIs?

thanks in advance!

 

function onChange(control, oldValue, newValue, isLoading) {
   if( newValue == 'agree'){
      var dialog = new GlideDialogWindow('terms_and_conditions_dialog'); //Render the dialog containing the UI Page 'terms_and_conditions_dialog'
   dialog.setTitle('Terms and Conditions'); //Set the dialog title
   dialog.setSize(600,600); //Set the dialog size
   dialog.removeCloseDecoration(); //Remove the dialog close icon
   dialog.setPreference('cancel_url', 'catalog_home.do?sysparm_view=catalog_default'); //Set optional cancel redirect URL
   dialog.render(); //Open the dialog
   }
}

1 ACCEPTED SOLUTION

LG2
Mega Expert

In the end we put the ts&cs into a macro with label variable and embedded them into a widget for the Service Portal with a variable width specified for the display. Not perfect, but the ts&cs are at least visible now.

View solution in original post

11 REPLIES 11

Brian Lancaster
Tera Sage

My guess would be that dialog is not support in Service Portal.  You may want to take a look at this info I found on the developer site.

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_GDW-GlideDialogWindow_S

Thank you - yes, you are correct, it isn't supported, which is why I'm asking for alternatives. 

The link you gave confirmed that our current coding is correct for what we have been using it for up until now, so I presume (and forgive me because I've only had one coffee today so far - and my coding tends to be 95% plagiarism) what you're pointing me to is for us to use this option instead - GlideModalV3?

 

var gm = new GlideModal('UI_dialog_name');
        //Sets the dialog title
        gm.setTitle('Show title');  			      	
        //returns the value of the title
        var title = gm.getPreference('title');
        gm.setWidth(550);
        //Opens the dialog
        gm.render(); 

woodyfairley
Tera Guru

Would you be able to present the terms and conditions in an alert box, or perhaps a confirm box? You may be able to overwrite the definition of the buttons with your own behaviors, and this simple approach should be easy to control in the script logic with IF conditions, and if you wanted to incorporate a field indicating the user's acceptance of the terms and conditions that also may be simple to incorporate into the script.

Perhaps this may work in the client script:

if(newValue == 'agree'){

    confirm('Terms and Conditions \nBy clicking the OK button, you agree to the following Terms and Conditions \n1. Feed the hungry \n2. end global warming \n3. stop eating animal products \n4. Volunteer at school

Well, instead of a silly scrap of code, take a look at this api reference page instead, it contains several code samples which may offer the alternative you seek (opens in new window):

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=SPM-confirm_S 

Kind Regards,

Woody

Thanks for the link Woody - my brain will try to decipher it slowly (it can't really do much else to be honest) but it looks very helpful.