Service Portal Error: Server Javascript error "\$sp" is not defined

reginabautista
Kilo Sage

Hi guys I am encountering   the below error when creating a new record.

find_real_file.png

The code below would update the Number of Requests on the Header Menu whenever a record is saved (current user):

find_real_file.png

The code is located in Service Portal Menu header-> Menu Items. Type   = Scripted List.

var st = new GlideRecord('myTable');

if (st.isValid()) {

  st.addActiveQuery();

  st.addQuery('opened_by', gs.getUserID());

  st.orderByDesc('sys_updated_on');

  st.setLimit(max);

  st.query();

  while (st.next()) {

      var a = {};

      $sp.getRecordValues(a, st, 'request_description,sys_id,number,sys_updated_on'); This is where the error is occuring

      if (st.request_description.nil())

      //   a.short_description = st.request_description;

      a.__table = st.getTableName();

      a.type = 'record';

  //   a.sortOrder = st.sys_updated_on.getGlideObject().getNumericValue();

      t.items.push(a);

  }

}

This code works perfectly for the Incident table. But for some reason is not working in my custom table. Any idea why?

1 ACCEPTED SOLUTION

No fix. An evangelist told me to open a HI ticket with ServiceNow.



I know this doesn't solve your problem, but it's a start.


View solution in original post

10 REPLIES 10

cmcclendon
Mega Guru

Is the custom table part of a scoped application? If so, the global getRecordValues method may not be accessible inside a scoped app. I have run into this with a scoped app before where the global applyTemplate method was inaccessible.


Hey Chris yep it is a scoped app. Any way to fix this? Cheers


No fix. An evangelist told me to open a HI ticket with ServiceNow.



I know this doesn't solve your problem, but it's a start.


Thanks Chris appreciate it.