getting Null value on assigned to

Programming

Hi developers 

need help whats wrong here why im getting null value on assigned to field from parent table (even there is value from parent request) which will be populated on change request . Assignment group and category is populating correctly while requested by field is null. 

Tia.

​

​

​

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        return;
    }
	
	var parent = g_form.getReference('parent') ;
	
    if (parent && parent.sys_class_name === 'sc_req_item') {
 var ga = new GlideAjax('epsChangeUtilstest');
    ga.addParam('sysparm_name', 'checkParentItem');
    ga.addParam('sysparm_parent', parent);
    ga.getXML(getResponse);
}
}



function getResponse(response) {
	//console.log("### this is result ", response);
    var answer = response.responseXML.documentElement.getAttribute('answer');
	//g_form.addInfoMessage('getResponse() = ' + parent + ', answer = ' + answer);
    if (answer !="false") {
        g_form.setValue("category", "Hardware");
		g_form.addInfoMessage('##Setting assigned_to ' + answer);
		g_form.setValue("requested_by",answer); //assigned_to
		//console.log("## assigned to", + answer + assigned_to);
		g_form.setValue("assignment_group","08a531782feb51507fcffe7cf699b682");
    }
}



===========
script include
===========
checkParentItem: function() {
        var parent = this.getParameter("sysparm_parent");
        var ritm = new GlideRecord("sc_req_item");
		ritm.addQuery('sys_id',parent);
		ritm.addQuery('sys_class_name', 'sc_req_item');
        ritm.query();
        if (ritm.next()) {		
			if (ritm.cat_item == '03c78de49f331200d9011977677fcf9f' || ritm.cat_item == '04b7e94b4f7b4200086eeed18110c7fd') {		
          //return ritm.assigned_to;
		return ritm.assigned_to.getValue();
        } else {
            return false;
        }}},

Posted Mar 30, 2023, 6:59 AM UTC

14
VeryAmaze•

What happens when you try this instead:

ritm.getValue("assigned_to");

1
_iamloveOP•

remains the same

1
GreeceReece•

Add an alert(parent); to your onChange script and make sure Parent is actually returning a value.

1
_iamloveOP•

This has been resolved in if else. Ty

1