- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 09:56 AM
Hi,
I have a requirement to populate the assignment group based on the service selected.
- if there is no value in assignment group field, populate the assignement group with the support group of service.
- If there is already a value in assignement group then it should ask for confirmation.
- and if the support group correlation Id starts with "I-" or "V-", it should not update the assignment group, else it should update the assignement group.
can anyone help me to achieve this ?
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var servicename = g_form.getValue('business_service');
var offering = g_form.getValue('service_offering');
var assignmentgrp = g_form.getValue('assignment_group');
if (servicename != '' && offering == '') {
if (assignmentgrp == '') {
service();
} else {
var ans = confirm('Are you sure want to update the assignment group with service support group');
if (ans == true) {
service();
}
}
}
function service() {
var getdata = new GlideAjax('AutopopulateAssignmentgroup');
getdata.addParam('sysparm_name', 'Getservicesupportgroup');
getdata.addParam('sysparm_service', servicename);
getdata.getXML(result);
}
function result(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('assignment_group', answer);
}
}
Script Include:
var AutopopulateAssignmentgroup = Class.create();
AutopopulateAssignmentgroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Getservicesupportgroup: function(){
var servicename = this.getParameter('sysparm_service');
var getgrp = new GlideRecord('cmdb_ci_service');
getgrp.addQuery('sys_id',servicename);
getgrp.query();
if(getgrp.next()){
var supportgroup = getgrp.getValue('support_group').toString();
if(supportgroup.u_correlation_id.indexOf('I-')==0)
return;
else
return supportgroup;
}
},
type: 'AutopopulateAssignmentgroup'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 02:02 PM
I think you could simplify it this way
Getservicesupportgroup: function(){
var servicename = this.getParameter('sysparm_service'); //sys_id of service
var getgrp = new GlideRecord('cmdb_ci_service');
getgrp.get(servicename); //goes straight to the service glide record
if(getgrp){ //if there is a glide record
var supGroupCorrId = getgrp.support_group.u_correlation_id.getDisplayValue();
if(supGroupCorrId.indexOf('I-')==0 || supGroupCorrId.indexOf('V-')==0)
return;
else
return getgrp.support_group; //sys_id of the support group
}
If I helped you with your case, please click the Thumb Icon and mark as Correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 07:56 PM
If i am using the above code, if the support group correlation id starts with "I-" or "V-" the assignment group value is clearing out, instead it should remain the value of assignment group