- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 01:08 PM
Hi, I have an onChange client script that is adjusting some options and it works great. I am trying to now also make it so that the comments field is no longer required. On line 25 I added 'g_form.setMandatory('comments', false);' like I have in other client scripts, however this is not working. Any reasons why this doesn't work?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
// get user title
var ga = new GlideAjax('FormCheckUtils');
ga.addParam('sysparm_name','recordFieldsClientDisplay');
ga.addParam('sysparm_tablename','u_itd_employee_cost_centers');
ga.addParam('sysparm_fields', 'u_employee_cost_center');
ga.addParam('sysparm_query', 'sys_id='+newValue);
// specify callback Function
ga.getXML((process));
function process(response) {
var value = response.responseXML.documentElement.getAttribute("answer");
value = value.split(',');
var cost_center = value[0];
if (cost_center.toUpperCase().indexOf("PTOT") != -1) {
g_form.showFieldMsg('u_event_code','This field is not mandatory but can make ESS reporting easier - TEST');
g_form.removeOption('u_event_code', 'HRPAY');
g_form.removeOption('u_event_code', 'HREXP');
g_form.removeOption('u_event_code', 'NTPAY');
g_form.setMandatory('comments', false);
g_form.setValue('comments', 'TEST');
}
else {
g_form.setVisible('u_event_code', false);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 03:32 PM
Just figured it out, cleared my browser cache and it started working properly. Thanks for your assistance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 01:15 PM
How did you make comments mandatory - dictionary entry, dictionary override, client script, UI Policy...? Is this on an table extended from task or a custom table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 01:20 PM
This is on the task_time_worked table and comments is set to mandatory via dictionary entry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 03:17 PM
Just to clarify, in a test case are you seeing the 3 choices removed, comments populated with 'TEST', but it's still mandatory? Do you happen to have any other client scripts or UI Policies affecting this field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2024 03:32 PM
Just figured it out, cleared my browser cache and it started working properly. Thanks for your assistance!