Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use data results from script include...

angeloorteg
Tera Contributor

Hi everyone... 

I am stuck right now and really appreciate any help.

 

I created a script include (server side) to fetch data via new GlideRecord and want to return them to the UI. 

 

Script Include (client callable: true, all application scopes, acl is there snc_internal)

```

var TG_TeamCalendarAppointmentService = Class.create();
TG_TeamCalendarAppointmentService.prototype = {
  initialize: function () {
    gs.info("Initialized TGTeamCalendarAppointmentService");
  },
  getEvents: function (opts) {
    opts = opts || {};
    var tableName = opts.tableName || 'sn_customerservice_appointment';
    var fields = opts.fields || {
      userRef: 'to',
      startField: 'start',
      endField: 'end',
      titleField: 'subject',
      groupLabel: 'to_users'
    };
    var out = { events: [] };

  ......
    return out;
  },
  type: 'TG_TeamCalendarAppointmentService'
};

```

Databroker Scriptlet 

```

function handler(input) {
      var svc = new TG_TeamCalendarAppointmentService();
      return svc.getEvents({..});
}
```

 

However, no matter how I want to call my script include in frontend - it wont work. 

Data Broker Scriptlet ->  GlideAjax and the Script Include Class Name are undefined / not found

UI Builder Client Script -> GlideAjax and the Script Include Class Name are undefined / not found

 

 

 

I am a bit lost and just need to understand the way of using script includes within my ui builder...

 

1 REPLY 1

angeloorteg
Tera Contributor

Hi everyone, 

 

so turns out I thought that I can use a DataBroker Scriptlet  for either Transform or as Scriptlet by changing the function name (since the title and subtitle of those entities look exactly the same) ... 
By deleting the scriptlet and creating a fresh Transform Databroker, I was able to call my Script Include (server) function and provide the data to the UI...