gs.log doesnt work on client script

kamleshpatel
Giga Contributor

Hi all,

I have a very basic question.   gs.log doesnt work on client scripts. I am using lot of alert to debug.. what are the alternatives ?

I know i can create ajax methods to create those logs.. but is there a simpler way???

~ Kamlesh

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kamlesh,



Any update on this?


Can you mark my 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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kamlesh,



Any update on this?


Can you mark my 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

Anurag Tripathi
Mega Patron
Mega Patron

Full list for anyone else seeking answer to the same question:



Scripting Alert, Info, and Error Messages - ServiceNow Wiki


-Anurag

PriyaRanji
Tera Guru

Hi Kamlesh,



Good Day



Please find the below details for your references:-



The following are one which works at server side and its functions:-



  • gs.log("test");writes to the database and the log file


  • gs.print("test"); writes to the text log on the file system but not to the sys_log table in the database


  • gs.addInfoMessage("test")it displays "test" on the top of the screen



The following are one which works at Client scripting and its functions:-



  • alert("test") — it pop up a window with "test" and an Ok button.


  • confirm("test") it pop up a window with "test" and along with Ok & Cancel button.


  • To show an error message in specific field g_form.showErrorBox('YOUR FIELD NAME','test');


  • To hide an error box which is visible in specific field, g_form.hideErrorBox('YOUR FIELD NAME');


gs.log() which you have mentioned in your script won't works since it will run only in server side not at client end.



Please mark it as helpful/correct based on the impact.



Thanks,


Priyanka R


Mohiyuddin Niza
Kilo Contributor

Thanks, PriyaRanji