Using a Client Script for a module definition

Michael Todd
Tera Contributor

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&colon;gs.beginningOfYesterday()@javascript&colon;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'
});

 

1 ACCEPTED SOLUTION

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Michael Todd ,

Try modifiying this line 

new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()

to 

new x_stpe_sports_data.SportsDataUtils().getCoveredFixtures()

 

Thanks,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

View solution in original post

2 REPLIES 2

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @Michael Todd ,

Try modifiying this line 

new x_stpe_sports_data.SportsDataUtils.getCoveredFixtures()

to 

new x_stpe_sports_data.SportsDataUtils().getCoveredFixtures()

 

Thanks,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Michael Todd
Tera Contributor

Thanks so much Omkar, such as easy fix! Probably would never have spotted that.