Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Client Script

Client script fires when category changes

Code Block
languagejs
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

Ui Page which shows the dialog

...

Code Block
languagexml
<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>

 

UI Action

catalog item sys_id is hardcoded right now, but it'll be read from the current records category info.

Code Block
languagejs
var url = "com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=6c80d6f66f323100fc62abcf9f3ee49f&sysparm_description=" + current.description + "&sysparm_short_description=" + current.short_description;
action.setRedirectURL(url);