Based upon assignment group, category fields to show dynamically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2021 02:33 AM
Create a category- assignment group mapping table and write client script and script include to handle the show hide if the category, if assignment group is not "software", category and subcategory related to software are not supposed to show up in the incident form.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 03:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 04:43 AM
Hi,
How to get the fields of incident category fields to the custom field of u_category [field] and custom table: u_assignment_category .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 04:53 AM
Hi snavuluri,
I would recommend using UI policy option here.
When possible, consider using a UI policy instead of a client script for these reasons:
- UI policies have an Order field to allow full control over the order in which client-side operations take place.
- UI policies do not require scripting to make a field mandatory, read-only, or visible.
Regards,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 11:18 PM
Hi All,
Please give solution for the below code. on load or on change the field value of assignment group, the value of the category field to changes automatically which is based upon the mapping table (as below).
And the code :
Script include: (Client callable) & for all scope application
var clientscriptprocessing = Class.create();
clientscriptprocessing.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssignmentGroup: function() {
var list = [];
var assignment_group = this.getParameter('sysparm_assignmentgroup');
var gr = new GlideRecord('u_category_assignment_group');
gr.addQuery('u_assignment_group', assignment_group);
gr.query();
while (gr.next()) {
var item_val = gr.getDisplayValue('u_category');
list.push(item_val);
}
return JSON.stringify(list);
},
type: 'clientscriptprocessing'
});
Client script: ( Table : incident, Type: onchange & field name: assignment group)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// g_form.clearOptions('category');
var cat = g_form.getValue('assignment_group');
var ga = new GlideAjax('clientscriptprocessing');
ga.addParam('sysparm_name', 'getAssignmentGroup');
ga.addParam('sysparm_assignmentgroup', cat); //.toString());
ga.getXML(getAssignmentGroup);
function getAssignmentGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var myObj = JSON.parse(answer);
if (myObj.length > 0) {
for (var i = 0; i < myObj.length; i++) {
g_form.setValue('category', myObj[i].toLowerCase(), myObj[i].toLowerCase());
}
}
}
}
Here issue is that, when loading / changed the incident record, getting the respective value but it is getting added and show in blue colour to the category field which suppose the select from existing values based upon mapping table and also to show only those respective fields.
When i uncomment the // g_form.clearOptions('category'); in client script, it is getting the value as required but showing in blue colour.
So, please give the solution that need to pass backend values instead of frontend values to fetch the properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 11:45 PM
Hi NSB,
You can use "On Change" client script
My Test case - If assignment group is "Problem Analyzer" then Category will change to "Hardware" automatically and "Sub category" will reflect accordingly
(Note - In script use "sys_id" of required group and backend value of Category)
and give dependency of "Sub Category" field on "category" field using configure dictionary.
Please mark Correct and Helpful if this really works for you.
Regards,
Shailesh Bachhav