Allow templates to set category and subcategory

Brian Lancaster
Tera Sage

We have created some incident templates and are trying to set the category and subcategory.  When someone clicks on the incident template it you can see it set the category and subcategory at first but then subcategory gets set to -- None --.  How can we make it so that system does not set the subcategory to -- None -- when using a template?

1 ACCEPTED SOLUTION

Nithish1
Tera Guru

Hello Brian,

 

We have the same issue and I figured it out, there is a oob client script "Empty assigned_to on group change" and I just commented one line of code [g_form.setValue("assigned_to", "");] and it worked.

 

Thanks,

Nithish

 

Hit Helpful or Correct on the impact of response.

 

View solution in original post

9 REPLIES 9

Tim Deniston
Mega Sage
Mega Sage

You may have to play around with where the Category and Subcategory are situated in the template. I have found that if I put the Subcategory first in the list of fields in the template and the Category last, it works correctly. Your situation may be different. Might want to try putting Category first and Subcategory last. Hopefully that works for you! 

After doing some testing it seems to be an issue with my client script that I have for on change of assignment group.  This script is changing what categories are available depending on the assignment group. 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	//Type appropriate comment here, and begin script below
	
	if (g_form.getValue('assignment_group') == 'a0cd82306f401f006f150f1aea3ee476'){
		g_form.clearOptions('category');
		g_form.addOption('category', '', '-- None --',0);
		g_form.addOption('category', 'Access Update', 'Access Update');
		g_form.addOption('category', 'Ad-hoc Request', 'Ad-hoc Request');
		g_form.addOption('category', 'Anomaly Monitoring', 'Anomaly Monitoring');
		g_form.addOption('category', 'Application Monitoring', 'Application Monitoring');
		g_form.addOption('category', 'Brand Protection Monitoring', 'Brand Protection Monitoring');
		g_form.addOption('category', 'Business Transaction Monitoring', 'Business Transaction Monitoring');
		g_form.addOption('category', 'Data Leakage-Reputation Monitoring', 'Data Leakage-Reputation Monitoring');
		g_form.addOption('category', 'Device Health Status', 'Device Health Status');
		g_form.addOption('category', 'Firewall Change', 'Firewall Change');
		g_form.addOption('category', 'Firewall Monitoring', 'Firewall Monitoring');
		g_form.addOption('category', 'Fraud and Transactional', 'Fraud and Transactional');
		g_form.addOption('category', 'Health Monitoring', 'Health Monitoring');
		g_form.addOption('category', 'Host Activity Monitoring', 'Host Activity Monitoring');
		g_form.addOption('category', 'Infrastructure (network)', 'Infrastructure (network)');
		g_form.addOption('category', 'Infrastructure Monitoring', 'Infrastructure Monitoring');
		g_form.addOption('category', 'Insider Threat Monitoring', 'Insider Threat Monitoring');
		g_form.addOption('category', 'Malware Defenses and Control Monitoring', 'Malware Defenses and Control Monitoring');
		g_form.addOption('category', 'Other Monitoring (Suspicious Traffic, etc)', 'Other Monitoring (Suspicious Traffic, etc)');
		g_form.addOption('category', 'Perimeter Monitoring', 'Perimeter Monitoring');
		g_form.addOption('category', 'Physical Access Monitoring', 'Physical Access Monitoring');
		g_form.addOption('category', 'Playbook', 'Playbook');
		g_form.addOption('category', 'Policy Enforcement Monitoring', 'Policy Enforcement Monitoring');
		g_form.addOption('category', 'Privileged User and Shared Account Monitoring', 'Privileged User and Shared Account Monitoring');
		g_form.addOption('category', 'security_incident', 'Security Incident');
		g_form.addOption('category', 'Service Monitoring', 'Service Monitoring');
		g_form.addOption('category', 'Service Request', 'Service Request');
		g_form.addOption('category', 'Tuning Recommendation', 'Tuning Recommendation');
		g_form.addOption('category', 'User Activity Monitoring', 'User Activity Monitoring');
		g_form.addOption('category', 'Vulnerability Monitoring', 'Vulnerability Monitoring');
	}
	else if (g_form.getValue('assignment_group') != 'a0cd82306f401f006f150f1aea3ee476'){
		g_form.clearOptions('category');
		g_form.addOption('category', '','-- None --',0);
		g_form.addOption ('category', 'how_to', 'How To');
		g_form.addOption('category', 'informational', 'Informational');
		g_form.addOption('category', 'network', 'Network');
		g_form.addOption('category', 'voice', 'Voice');
		g_form.addOption('category', 'Security Incident', 'Security Incident');
	}
}

I have narrowed it down to the code after the clearOptions which is g_form.addOption('category', '','-- None --',0);.  Once I remove that it works thought a template but if I change the assignment group it auto-populates with the first category in the list.

I think there is just too much going on with applying the template and using client scripts to manage the values that are shown. 

 

There is a parameter in the onChange function called isTemplate. You may be able to use that to determine if your client script should run or not. Maybe you can trust the template to have the right values and not use clearOptions, addOption in that scenario.