4 Replies · Latest reply on Sep 15, 2017 9:16 AM by Adam Kaupisch

    sys_db_object query getting error inside scope application

      Ultimately, what I'm trying to do is get all child tables of a parent table. The TableUtils will not work as GlideDBObjectManager cannot be called from within a scoped application...so I figured I'd write my own...Only I'm getting an error: Method "query" called on incompatible object.

       

      My code sits at the global app:

      getAllExtensions: function(tableName) {
           var gr = new GlideRecord('sys_db_object');
           gr.get('name', tableName);
      
           var arr = new Array();
           var subs = new GlideRecord('sys_db_object');
           subs.addQuery('super_class', gr.sys_id);
           subs.query();
           while (subs.next())
                arr.push(subs.name.toString());
      
           return arr;
      },
                },
      }
      

       

      This works perfectly fine if I run inside global, if I execute the same code in my scoped, I get the above error.

       

      sys_db_object table is accessible from all app scopes, and 'Can Read' is checked. ACLs show that you just need itil role (which I have, I'm admin) to read...

       

      Is there something I'm missing, does SN have this locked down in some way that isn't visible? Any help would be appreciated. Remember, my goal is to get all child tables from a parent table's name.

       

      EDIT: For clarification my current schema is as follows:

      Global Script Include: has the above getAllExtensions function

      Scoped Script Include: has a function getSomething() that basically does: return new global.MyScriptInclude().getAllExtensions('x_abc_abc_requests').join(',');

      Scope Module: List of Records with argument: sys_class_nameINjavascript:new x_abc_abc.MyScopedScriptInclude().getSomething();

      This fails....

       

      However, I just found that if I skip the global script include and simply copy the getAllExtensions code into my scoped script include, it magically works. I verified that all script includes involved have All application scopes. I have a work around as a result, but that still doesn't explain what is going on. Is this a bug or WAI?

      Please Like, Mark Helpful, or Correct Answer if it applies.