We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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

Hello David,



You may find the below thread helpful.


gliderecord functions within a scoped application


Chay2
Giga 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.