- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2015 11:36 PM
Good day all,
I am busy with creating a custom application and tried to create an application Script Include. I am trying to call a basic function (in this case getFields)
This however gives me an error, what is the correct way of using/create a script like this
Code |
---|
var MyScript = Class.create(); MyScript.prototype = { initialize: function() { }, test : function(current) { var fields = current.getFields(); },
type: 'MyScript' }; |
Error |
---|
Function getFields is not allowed in scope x_company_test |
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2015 11:47 PM
Hi Wallace,
getFields() is a function of GlideElement, which is globally accessible.
See http://wiki.servicenow.com/index.php?title=Scoped_System_API
Another thing, I wanna point out is getFields will work only with glide Objects like GlideRecord object or current in BR.
--
Cheers,
AR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2015 11:47 PM
Hi Wallace,
getFields() is a function of GlideElement, which is globally accessible.
See http://wiki.servicenow.com/index.php?title=Scoped_System_API
Another thing, I wanna point out is getFields will work only with glide Objects like GlideRecord object or current in BR.
--
Cheers,
AR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2015 12:52 AM
Thanks,
used the below and it seems to have fixed my issue
var gr = new GlideRecord('x_company_test_ticket');
gr.addQuery('sys_id',current.sys_id);
gr.query();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2015 04:52 PM
Hi All -
Has anything changed with regards to this answer? I'm on a UI Action to test getFields() and both of these fail within my scoped application:
// Fails...
//var fields = current.getFields();
//gs.addInfoMessage('fields: ' + fields);
// Also fails...
var gr = new GlideRecord('x_7940_xyz_customer');
gr.get(current.sys_id);
gs.addInfoMessage('sys_id: ' + gr.sys_id); // good GlideRecord, sys_id displays
var fields = gr.getFields(); // creates error: Function getFields is not allowed in scope x_7940_xyz
Thanks!
Ben