Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

getFields in scoped app

davilu
Mega Sage

We are developing in a scoped application and cannot use getFields().   How can we revise the below code so that it works in a scoped app?

var fields = gr.getFields();

gs.addInfoMessage(data.sys_id);

totalFields = fields.size();

for (var i=0; i<fields.size(); i++){

var glideElement = fields.get(i);

if(glideElement.hasValue()){

answeredFields++;

}

}

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello David,



You may find the below thread helpful.


gliderecord functions within a scoped application


Chay2
Mega Guru

Hi David,



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.