- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 08:58 AM
Hi All,
Hoping someone can help with my issue. I am trying to use a client script to dynamically build the query filter for a module definition.
I have scoped application called "Sports Data" (x_stpe_sports_data) which includes tables called
x_stpe_sports_data_fixtures (parent table) and x_stpe_sports_data_fixture_coverage (child table). I have then created a script include (below) to fetch the fixtures I need for a new module, using records from the child table. The script is client callable and available to all scopes.
The definition of the module is:
Link Type: URL (from arguments)
Arguments: /x_stpe_sports_data_fixtures_list.do?sysparm_query=sys_idINjavascript:new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()
I have tested the function separately in a background script and that works fine. When I click on the module I get the following error in the log:
com.glide.script.RhinoEcmaError: undefined is not a function.
<refname> : Line(1) column(0)
==> 1: new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()
Appreciate help anyone can offer.
Mike.
var SportsDataUtils = Class.create();
SportsDataUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getCoveredFixtures: function(){
var coveredFixturesList = '';
var seperator = '';
var covFix = new GlideAggregate('x_stpe_sports_data_fixture_coverage');
covFix.addEncodedQuery('x_stpe_sports_data_fixtures.start_timeONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()^x_stpe_sports_data_fixtures.sport=43235da91bbd759017c0748bd34bcbde');
covFix.addAggregate('count');
covFix.orderByAggregate('count');
covFix.groupBy('x_stpe_sports_data_fixtures');
covFix.query();
while(covFix.next()){
if(coveredFixturesList.length > 0)
seperator = ',';
coveredFixturesList = coveredFixturesList + seperator + covFix.x_stpe_sports_data_fixtures;
}
return 'sys_idIN' + coveredFixturesList;
},
isPublic:function(){return true;},
type: 'SportsDataUtils'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 10:01 AM
Hello @Michael Todd ,
Try modifiying this line
new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()
to
new x_stpe_sports_data.SportsDataUtils().getCoveredFixtures()
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 10:01 AM
Hello @Michael Todd ,
Try modifiying this line
new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()
to
new x_stpe_sports_data.SportsDataUtils().getCoveredFixtures()
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 10:37 AM
Thanks so much Omkar, such as easy fix! Probably would never have spotted that.