sys_db_object query getting error inside scope application

akaupisch
Kilo Guru

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?

4 REPLIES 4

Raju Koyagura
Tera Guru

I tried the same in my dev isntance and it worked fine. Did you check the Cross Scope Privileges



find_real_file.png


So I added the cross scope privileges, but nothing changed. I'm still getting that error...here's some SSs:



Module:


Screen Shot 2017-09-14 at 11.00.31 AM.png



Scoped Script:


Screen Shot 2017-09-14 at 11.01.45 AM.png



Global Script:


Screen Shot 2017-09-14 at 11.02.26 AM.png


Screen Shot 2017-09-14 at 11.02.55 AM.png



Cross Scope Priv:


Screen Shot 2017-09-14 at 11.03.38 AM.png


Screen Shot 2017-09-14 at 11.43.55 AM.png


I have since updated the requested to Allowed for the GlideAPI



error message:


Screen Shot 2017-09-14 at 11.04.43 AM.png



Any other thoughts? If I copy the global into the scoped script, it works just fine. What is it about being in global that is throwing it off?


Raju Koyagura
Tera Guru

Did you try this way in argumnets?


Since you are calling global SI in Scoped SI, directly call that global SI in arguments


sys_class_nameINjavascript: new global.TBCGlideRecordUtils().getAllRequests()


I tried that, and now I'm getting another error: 'undefined is not a function. Caused by error in <refname> at line 1. ==> 1: new global TBCGlideRecordUtils().getAllRequests()'



I have TBCGlideRecordUtils defined in the cross scope, and it is All application scopes...something really funky is going on...