Logging the script include

Avinash Dubey2
Tera Contributor

I have written this script include :I want to add log message in this since this code is not working also were to checks the logs in service now 

 

var Configuregroupbasedonassigned = Class.create();
Configuregroupbasedonassigned.prototype = {
    initialize: function() {
    },
    
    getGrpMembers:function(u_ser)
    {
        //var GrpU= current.variables.u_assigned_to;
        if(u_ser=="")
            {
                return;
            }
        var GrpMember= new GlideRecord('sys_user_grmember');
    //    gs.info(u_ser);
        //gs.info(GrpMember);
        GrpMember.addEncodedQuery('user='+u_ser);
    //    GrpMember.addEncodedQuery('group='+Grp);
    //    GrpMember.addQuery('user','Grp');
        GrpMember.query();
        var Groups = [];
        while(GrpMember.next())
            {   
                Groups.push(GrpMember.group.toString());
                
            }
    //    gs.info(GrpMember);
        return 'sys_idIN'+Groups.toString();
        
    },
       
    type: 'Configuregroupbasedonassigned'
};

1 ACCEPTED SOLUTION

Valmik Patil1
Kilo Sage

Hi Avinash,

if your script include is in Global scope you can use gs.log() to print log

if your script include is in Scoped scope you can use gs.info() , gs.warn()  ,gs.error(), gs.debug( )to print log

ex. gs.log("Test log Script include");

Always try yo add unique text in log so that it will be easy to search

Also please refer below to check the logs ,Always try to sort by created to get latest logs

find_real_file.png

Thanks 

Valmik

View solution in original post

3 REPLIES 3

Charles Louis1
Giga Expert

Hi 

You can search for System log->ALL in application navigator.

 

Please Mark it as correct if its helpful.

Valmik Patil1
Kilo Sage

Hi Avinash,

if your script include is in Global scope you can use gs.log() to print log

if your script include is in Scoped scope you can use gs.info() , gs.warn()  ,gs.error(), gs.debug( )to print log

ex. gs.log("Test log Script include");

Always try yo add unique text in log so that it will be easy to search

Also please refer below to check the logs ,Always try to sort by created to get latest logs

find_real_file.png

Thanks 

Valmik

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can add gs.info() and search in System Logs module

Can you share script include and client script are in same scope?

share screenshots for both

Regards
Ankur

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