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

 

2 ACCEPTED SOLUTIONS

@Adarsh kumar si 

for existing one it won't allow

please create new and then set it and use that

💡 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

TharaS657398130
Tera Guru

Hey!

The main issue is the scope. Your Script Include is in a scoped application, but the Company list filter is running from the Global scope. 

The simplest fix is to change the Script Include Accessible from to All application scopes and make sure the Script Include is client-callable only if you actually need it from the client side. If Accessible from is stuck on This application scope only, don't try to force it from the field. Avoid calling that scoped Script Include directly from the Global Company list filter. I would say use a reference qualifier instead of javascript:GetCompany()

View solution in original post

5 REPLIES 5

TharaS657398130
Tera Guru

Hey!

The main issue is the scope. Your Script Include is in a scoped application, but the Company list filter is running from the Global scope. 

The simplest fix is to change the Script Include Accessible from to All application scopes and make sure the Script Include is client-callable only if you actually need it from the client side. If Accessible from is stuck on This application scope only, don't try to force it from the field. Avoid calling that scoped Script Include directly from the Global Company list filter. I would say use a reference qualifier instead of javascript:GetCompany()