call script include in a report condition

kunal16
Tera Expert

Hi All,

I have a script include which returns the sys_id of RITMs created on this month. I am trying to call that script include in the condition for a report like - Sys ID is one of javascript: new myRITM().thisMonthRITMs()

But I am not able to fetch any record in my report.

P.S. - I know that this can be done using the filter Created on This month, but I want to do it with a script include

Here is my script include:

Name: myRITM

Client callable: FALSE

Script:

var myRITM = Class.create();

myRITM.prototype = {

  initialize: function() {

  },

  thisMonthRITMs : function()

  {

            var arr = [];

            var querystring = 'active=true^sys_created_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()';

            var ritm = new GlideRecord('sc_req_item');

            ritm.addEncodedQuery(querystring);

            ritm.query();

            while (ritm.next())

            {

                      arr.push(ritm.sys_id);

            }

            gs.log('@@ ' + arr);

            return arr;

  },

  type: 'myRITM'

};

Any help will be appreciated.

Thanks in advance!!

7 REPLIES 7

dvp
Mega Sage
Mega Sage

Can you update the return statement to


return sys_idIN + arr.toString();


and try again


Hi dvp,


I have tried that as well but no success!!


can you update this statement as well


arr.push(ritm.sys_id);


to


arr.push(ritm.sys_id.toString());


Tried that as well but still no success.