write a script include to get sysid of assignment group

shikhakamboj
Kilo Expert

i want to write a script include to get the sysids of assignment groups and than call that script include in client script.

need example.

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shikha,



You need to use GlideAjax if you want to call script include from client script.



Example below:


GlideAjax


GlideAjax Example Cheat Sheet



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

SNOW User8
Giga Guru

Hi Shikha Kamboj




Script Include to get all group sysids,



        var groupSysID = Class.create();


        groupSysID.prototype = Object.extendsObject(AbstractAjaxProcessor, {


        getAssignmentGroupSysID : function(){


        var assignmentGroupArray = [];


        var assignmentGroupName = [];


        var gr = new GlideRecord('sys_user_group');


        gr.addQuery('active',true);


        gr.query();


        while(gr.next()){


        assignmentGroupName.push(gr.getUniqueValue());


        }


        return assignmentGroupName.toString();


        },


      type: 'groupSysID'


        });



find_real_file.png



Client script to get values,


For testing I have set the values in description, you change the logic as you need.



      function onLoad() {


    //Type appropriate comment here, and begin script below


      var ga = new GlideAjax('groupSysID');


      ga.addParam('sysparm_name', 'getAssignmentGroupSysID');    


      ga.getXML(AssignmentGrpupSysID);




        }    



        function AssignmentGrpupSysID(response) {


      var answer = response.responseXML.documentElement.getAttribute("answer");


        alert(answer);


        g_form.setValue('description', answer);


        }



find_real_file.png


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shikha,



Any update on this?


Can you mark answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader