Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to use script include function in report

VallabhiAgr
Tera Contributor

script include :

var BlankRequestChecker = Class.create();
BlankRequestChecker.prototype = {
    initialize: function() {},

 

    getBlankRequestList: function() {
        var blankRequestSysIDs = [];
        var req = new GlideRecord('sc_request');
        req.addQuery('active'true);
        req.query();

 

        while (req.next()) {

 

            var ritm = new GlideRecord('sc_req_item');
            ritm.addQuery('request', req.sys_id);
            ritm.query();
            if (ritm.hasNext()) continue;

 

            var approval = new GlideRecord('sysapproval_approver');
            approval.addQuery('sysapproval', req.sys_id);
            approval.addQuery('state''requested');
            approval.query();
            if (approval.hasNext()) continue;

 

            var task = new GlideRecord('sc_task');
            task.addQuery('request', req.sys_id);
            task.addQuery('active'true);
            task.query();
            if (task.hasNext()) continue;

 

            blankRequestSysIDs.push(req.sys_id.toString());
        }

 

        return blankRequestSysIDs;    
    },

 

    type: 'BlankRequestChecker'
};

This is how I call it in report, it is showing error 
VallabhiAgr_0-1765363840276.png

 

1 ACCEPTED SOLUTION

@VallabhiAgr 

did you run your script include in background and you are getting result i.e. sysIds?

also Sandbox checkbox if not on Form, then from list make it true

AnkurBawiskar_0-1765372838836.png

Configuring Script sandbox property 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@VallabhiAgr 

did you run your script include in background and you are getting result i.e. sysIds?

also Sandbox checkbox if not on Form, then from list make it true

AnkurBawiskar_0-1765372838836.png

Configuring Script sandbox property 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

I have enabled sandbox from list view it's working. Thank you