How to set the script include filter values in Onchange clinet script Reference variable ?

raj99918
Tera Contributor

Hi,

 

Am calling script include and getting the filter values as well but not able to set those values in OnChnage client script of Reference(Groups table) variable.

Below is my Onchange script please let me know what.s the issue here?

-----------------------

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var gajax = new GlideAjax('Groupsdata');
    gajax.addParam('sysparm_name', 'getGroupnames');
    gajax.addParam('sysparm_userID', newValue);
    gajax.getXML(getResults);
}
function getResults(response) {
 var answer = response.responseXML.documentElement.getAttribute("answer");
var user = g_form.getValue('requested_for');
    if (user != '') {
         alert(answer);
         var groupSysIds = answer.split(',');
g_form.setValue('assignment_group', groupSysIds.join(','));
}
}
1 ACCEPTED SOLUTION

@raj99918 Please update the script include script as follows.

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

    getGroupnames: function(user) {
        var groups = [];        
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('user', user);
        gr.query();
        while (gr.next()) {
            groups.push(gr.group.sys_id);
        }
        return 'sys_idIN' + groups.toString();         
    },
type: 'Groupsdata'
});

Also, apply the same reference qualifier again on the Group field in order to make the reference qualifier call the script include.

View solution in original post

8 REPLIES 8

@raj99918 Please update the script include script as follows.

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

    getGroupnames: function(user) {
        var groups = [];        
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('user', user);
        gr.query();
        while (gr.next()) {
            groups.push(gr.group.sys_id);
        }
        return 'sys_idIN' + groups.toString();         
    },
type: 'Groupsdata'
});

Also, apply the same reference qualifier again on the Group field in order to make the reference qualifier call the script include.

Hi @Sandeep Rajput  Sorry still it's not pulling the filter values and its getting all the group names.

 

@raj99918 Sent you a message, please check.

raj99918
Tera Contributor

Hi @Ankur Bawiskar  Can you please help me here