Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

script include filter not working on company table

Adarsh kumar si
Tera Contributor

Hello team,
I am trying to filter out the company  in company table which are used in "Business Application" table .
I have created script include which is in different scope than global scope and accessible from is "This application scope only" 

Script :--

function GetCompany() {

    var companies = [];

    var ga = new GlideAggregate('cmdb_ci_business_app');

    ga.addNotNullQuery('company');

    ga.groupBy('company');

    ga.query();

    

    while (ga.next()) {

        companies.push(ga.getValue('company').toString());

    }

      return companies.join(',');

}


.................................................................

And  on company table filter is :--sysid is one of javascript:GetCompany()

when i run the filter it becomes sysid in NULL.


NOTE:-- I have checked sandbox enabled.

thank you

 

1 REPLY 1

Ankur Bawiskar
Tera Patron

@Adarsh kumar si 

1st issue is the accessibility.

Script include can't be called unless you make it Accessible from All scopes

Did you try updating that?

from where are you calling that? share screenshots

💡 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