3.In change Form - Based on the Service selected , Assigned group has to be poppulate

nameisnani
Mega Sage

Hi Team , 


we have requirement that , In change request ,  Based on the Service selected , that Service Support group has to be populate in the Assignment group .

 

See in the Below screenshot , Service is Firewall NonProd and the Support Group is TCS-Network-SUP >> And the Same support group has to be populate in the assignment group .

 

 

How to fulfill this requirment , can any one please provide script for this , Please provide screenshot for better understanding .

 

Please provide test cases screenshot 

nameisnani_0-1727945369826.png

 

please provide configuration screenshots

3 REPLIES 3

Mark Manders
Mega Patron

Answer already provided, both times you asked the exact same thing:

https://www.servicenow.com/community/developer-forum/in-change-form-based-on-the-service-selected-as...

https://www.servicenow.com/community/developer-forum/1-in-change-form-based-on-the-service-selected-...

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Anwesha3
Mega Guru

Hi @nameisnani 

The non code way to do this is Assignment rule . 

or by OnChange client script you can achieve the same. 

In case of On Change client script; you need to create a  script on change of "Service" in the script section add If logic to check if newValue == < the service you are trying to apply the logic for > 
{
set value for assignment group field ( get value - service.supportgroup)
}

Kindly mark the reply as a correct answer / helpful if it helped to solve your question.

Thanks,
Anwesha



yaswanthi2
Giga Sage

Hi @nameisnani 

You can create onChange client script for change request table with field as "service". Below is the code

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue) {
        var ga = new GlideAjax('ajaxUtils');
        ga.addParam('sysparm_name', 'getServiceSupportGroup');
        ga.addParam('sysparm_serviceId', newValue);
        ga.getXMLAnswer(callSupportGrp);
    }

    function callSupportGrp(answer) {
        var supportGroupId = answer;
        g_form.setValue('assignment_group', supportGroupId); // set the field name correctly as per your field name
    }
}

 

Script Include(client callable)

var ajaxUtils = Class.create();
ajaxUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getServiceSupportGroup: function(){
		var sprtGrp;
		var serviceId = this.getParameter('sysparm_serviceId');
		var grService = new GlideRecord('cmdb_ci_service'); // service reference field table name
		if(grService.get(serviceId)){
			sprtGrp = grService.support_group;
		}
		return sprtGrp.toString();

	},

    type: 'ajaxUtils'
});

 

Regards,

P Yaswanthi.

Please mark this response as correct or helpful if it assisted you with your question.