POP location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:10 PM
I have configured a field on the sn customerservice task form where the reference is to the cmdb ci site table, and you want to automatically populate the Assignment Group field based on the selected site, In site has one attribute support group ,I have to populate that field value into Assignment group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:16 PM
Achieving this task can be approached through various methods such as Client script & GlideAjax, Assignment rule, or Business rule. For example, you can create a "before" Business rule on the task table with a condition based on CMDB changes. Here's a sample script:
if (current.cmdb_ci.support_group)
{
current.assignment_group = current.cmdb_ci.support_group.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:19 PM
Let me know how to write Client script & GlideAjax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:34 PM
Client Script:
Type: On change
Filed: CMDB
UI Type: All
Script:
New script include:
Name: assignmentRuleUtil
client callable: True
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2024 08:34 PM
Hi @Anusha Medharam ,
I trust you are doing great.
Please find the client script and script include for the same as given below:
Script include :
var GetSupportGroup = Class.create();
GetSupportGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSupportGroup: function() {
var site = this.getParameter('site');
// Query the CMDB CI Site table to get the support group for the selected site
var siteGr = new GlideRecord('cmdb_ci_site');
if (siteGr.get(site)) {
return siteGr.getValue('support_group');
}
return ''; // If support group is not found, return empty string
}
});
Client script :
// Client script to populate Assignment Group based on selected site
function onChangeSite() {
var site = g_form.getValue('cmdb_ci'); // Assuming 'cmdb_ci' is the field name for the site reference
// Call GlideAjax to get the support group for the selected site
var ga = new GlideAjax('GetSupportGroup');
ga.addParam('sysparm_name', 'getSupportGroup');
ga.addParam('site', site);
ga.getXMLAnswer(populateAssignmentGroup);
}
function populateAssignmentGroup(response) {
var assignmentGroup = response;
// Set the value of Assignment Group field
g_form.setValue('assignment_group', assignmentGroup);
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi