populate the group members name and email id

yaswanth123
Tera Contributor

Hi,

i need to populate the group member names and email id in one field using group member reference. Using the script include and catalog client script.

1 REPLY 1

Community Alums
Not applicable

Hi,

Please update accordingly.

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

    var ga = new GlideAjax("onChangeCICSTnDClass");
    ga.addParam("sysparm_name", "onChangeCICSTnDFunction");
    ga.addParam("sysid_key", newValue);
    ga.getXML(callBackFunction);

    function callBackFunction(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        var op = JSON.parse(answer);
        g_form.setValue("job_title", op.callerTitle);
        g_form.setValue("department", op.callerDepartment);
    }
}

Script Include

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

    onChangeCICSTnDFunction: function() {
        var sysPar = this.getParameter("sysid_key");
        var objGR = new GlideRecord("sys_user");
        objGR.addQuery("sys_id", sysPar);
        objGR.query();
        while (objGR.next()) {
            var jsonObj = {};
            jsonObj.callerTitle = objGR.getValue("title");
            jsonObj.callerDepartment = objGR.getDisplayValue("department");
			var json = new JSON().encode(jsonObj);
			return json;
        }
		return "";
    },

    type: 'onChangeCICSTnDClass'
});

 

Regards

Suman P.