Glide Record not working on Client Script

jmcagod
Kilo Guru

So, Ive learned that there is a Client-Side Glide record, however there's not much of a difference between them except fewer functions

and the way its coded.

I read the API and tried that on my client script onSubmit. And when I tried it, it gave me an Error:

onSubmit script error: TypeError: GlideRecord is not a function:

function (){var o=i(m,arguments);return l.apply(n,o)}

What I'm currently trying to do is to get something out of the database.

function onSubmit()

{

   

  var mngrsysid = g_form.getValue('sys_id');

  var noOfEmp = 0;

  var emptable = new GlideRecord('x_21272_jobmgmtapp_employees');

  emptable.addQuery('number', mngrsysid);

  emptable.query(recResponse);

  function recResponse(emptable)

  {

  while(emptable.next())

  {

  g_form.addInfoMessage('Emp No: ' + emptable.number);

  }

}

Can someone please help me figure it out, and tell me what I'm doing wrong.

1 ACCEPTED SOLUTION

Artemis15
Kilo Guru

Jamie,



From your written code, it seems that you are in scoped application and in scoped application Client side Glide Record is not present. Better is you use Script Include and by the way, Best practice is not to use Client side glide record.



--


Cheers,


AR


View solution in original post

4 REPLIES 4

Michael Fry1
Kilo Patron

What happens if you remove the Function form the middle of the gliderecord? So:


function onSubmit() {


      var mngrsysid = g_form.getValue('sys_id');


      var noOfEmp = 0;


     


      var emptable = new GlideRecord('x_21272_jobmgmtapp_employees');


      emptable.addQuery('number', mngrsysid);


      emptable.query(recResponse);


      while(emptable.next()) {


              g_form.addInfoMessage('Emp No: ' + emptable.number);      


      }


}


Artemis15
Kilo Guru

Jamie,



From your written code, it seems that you are in scoped application and in scoped application Client side Glide Record is not present. Better is you use Script Include and by the way, Best practice is not to use Client side glide record.



--


Cheers,


AR


Okay! Thank you! I created a business rule now instead of a Client Script. Thanks!


Abbas7
Tera Contributor

Client Script Best Practices - ServiceNow Wiki



Regards


Mir Hassan Abbas Razvi