Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Client script fires when category changes

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue == '') {
		return;
	}
	
	//Type appropriate comment here, and begin script below
	conversionDialog();
	
	function conversionDialog() {
		//Get the values to pass into the dialog
		var requester = g_form.getReference('u_requester');
		
		var gr = new GlideRecord('sc_cat_item');
		if (gr.get(g_form.getReference('u_category').u_catalog_item)) {
			var item = gr.name;
		}
		
		//Initialize and open the dialog
		var dialog = new GlideDialogWindow("conversion_dialog"); //Instantiate the dialog containing the UI Page 'add_comments_dialog'
		dialog.setTitle("Ticket Conversion"); //Set the dialog title
		
		dialog.setPreference("catalog_item", item); //Pass the item name to the dialog
		dialog.render(); //Open the dialog
	}
}

Ui Page which shows the dialog

A couple of questions, special things happening here:

  • Hiding the (error) close button since there isn't an event we can capture here
  • Should the cancel call a function or script here?  There's only two things it's doing here.
<g:ui_form>
  <!-- Get the values from dialog preferences -->
<g:evaluate var="jvar_catalog_item"
    expression="RP.getWindowProperties().get('catalog_item')" />
<g:evaluate var="jvar_cuser"
    expression="RP.getWindowProperties().get('cuser')" />
<g:evaluate var="jvar_cuser_name"
    expression="RP.getWindowProperties().get('cuser_name')" />
   <!-- Set up form fields and labels -->
<style>
#popup_close_image
{
display:none;
}
</style>   
<table width="100%">
     <tr id="description_row" valign="top">
        <td colspan="2">
           <!-- Short description value used as a label -->
           A catalog item is available for this service offering and category combination.  This ticket will be converted to the available catalog item '${jvar_catalog_item}'.
        </td>
     </tr>
     <tr>
       <td colspan="2">
<!-- Requester : <g:ui_reference name="cuser" id="cuser" table="sys_user" value="${jvar_cuser}" displayvalue="${jvar_cuser_name}"/> -->
       </td>
     </tr>
     <tr id="dialog_buttons">
        <td colspan="2" align="right">
           <!-- Add OK/Cancel buttons. Clicking OK calls the validateComments script -->
           <g:dialog_buttons_ok_cancel ok="gsftSubmit(null, g_form.getFormElement(), 'convert_incident');" ok_type="button" cancel_type="button" cancel="g_form.setValue('u_category',false);GlideDialogWindow.get().destroy();" />
        </td>
     </tr>
  </table>
</g:ui_form>

 

 

  • No labels