GlideDialogWindow

Lohith
Giga Expert

Hi All,

I have a requirement like,

Condition : when supplier field on incident table is Vendor

Requirement : when condition is met, I need to create a glide dialog window, which opens a survey page. user will fill out the survey page and clicks on save button on dialog window, Page should remain on parent window ie on current incident form, At this point of time incident form should not be saved, user will still edit fields on current incident form and then clicks on save.

Any inputs will be greatly appreciated, Thanks

Regards,

Lohith

1 ACCEPTED SOLUTION

The client script for generating the window is pretty simple.   Since you are looking for one specific vendor as the supplier then you can hard code the sys_id in the client script and whenever someone puts that value in the supplier field it will pull up your UI page.   That part you will have to build to look the way you want and store the results in whatever table/fields you are interested in.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if (isLoading || newValue == '') {


  return;


}



//Type appropriate comment here, and begin script below



if(newValue == 'sys_id_of_vendor')   // Enter the sys_id of Vendor


  {


  var dialog = new GlideDialogWindow('your_ui_page'); // Change this to your UI page


  dialog.setTitle('Vendor Survey'); // Change this to whatever you want the title bar of the dialog to say


  dialog.render();


  }


}



-Steve


View solution in original post

9 REPLIES 9

Steve McCarty
Mega Guru

This page should give you a good starting place if you haven't seen it:   Displaying a Custom Dialog - ServiceNow Wiki.   Basically you will first need to create or find a UI Page that will display your survey (survey_take may do what you need).   Then you need to create a client script that will display that page using the GlideDialogWindow API when your conditions are met.   You can do an onChange client script for your supplier field and then check to see if the newValue is the Vendor you are looking for.   If so, you can create a GlideDialogWindow object for your UI Page, pass it some parameters if needed, and then render the page.  



The dialog window will open on top of the incident form.   It won't allow you to edit the incident form until the dialog box is closed, but it doesn't change or save the incident form either unless the UI Page has a client script set up to do that.



Do you want to pop up the survey as soon as the supplier field changes or some other time?   Is the vendor a specific value or is that another field on the incident form?



-Steve


Hi Stephen,



We have Supplier field on incident form and it is reference field. When the value is Vendor then we need to open survey in a dialog window. Then user will fill all details in that survey and submits the survey. Once the user submit survey, the dialog window should close but incident should not save until we save the incident form.


Lohith,



AS stephen suggested above, a client script onChange would be the best to test the input value of Supplier field.


As soon as the value is equal to 'Vendor', it will trigger the ui page and will display the survey.


Few notes :


1. As said, Supplier is a refereced field, therefore you will get the sys_id. A glideAjax is necessary to get the displayValue of the suppier field.


Please refer to this following thread for the GlideAjax : GlideAjax - ServiceNow Wiki



2. Here is another interesting article concerning GlideDialogWindow. In fact, this thread shows how to display a dialog window with custom informations and also how to return the chosen value (from the dialog box) to the initial form. GlideDialogWindow: Advanced Popups Using UI Pages - ServiceNow Guru



I hope that will help you to achieve the survey



Feel free to contact me if you have more concerns



Kind regards,


ZA


Do not feel shy to mark correct or helpful answer if it helps or is correct


The client script for generating the window is pretty simple.   Since you are looking for one specific vendor as the supplier then you can hard code the sys_id in the client script and whenever someone puts that value in the supplier field it will pull up your UI page.   That part you will have to build to look the way you want and store the results in whatever table/fields you are interested in.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


if (isLoading || newValue == '') {


  return;


}



//Type appropriate comment here, and begin script below



if(newValue == 'sys_id_of_vendor')   // Enter the sys_id of Vendor


  {


  var dialog = new GlideDialogWindow('your_ui_page'); // Change this to your UI page


  dialog.setTitle('Vendor Survey'); // Change this to whatever you want the title bar of the dialog to say


  dialog.render();


  }


}



-Steve