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.

Guest Gliderecord returing 0 records

snowcone
Giga Guru

Simple widget to query records, as a guest user is not returning records: Works perfectly when logged in.

 

Widget Server Script:

---------------------------

var gr = new GlideRecord('incident');
        gr.addActiveQuery();
        gr.query();
        data.incidents = []; 
     
    gs.info('TEST the GR Count ' + gr.getRowCount()); //This Returns 0 as a Guest user
    while (gr.next()) {
            data.incidents.push({
                number: gr.getValue('number'),
                short_description: gr.getValue('short_description'),
                state: gr.getDisplayValue('state')
            });
        }
 
HTML
--------------------------
<div class="panel panel-default">
<div class="panel-heading">Active Incidents</div>
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th>Number</th>
<th>Short Description</th>
<th>State</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="incident in data.incidents">
<td>{{incident.number}}</td>
<td>{{incident.short_description}}</td>
<td>{{incident.state}}</td>
</tr>
</tbody>
</table>
</div>
</div>

 

What is it that prevents GlideRecord to return 0 count as a guest? Thanks for the help.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@snowcone 

try to use setWorkflow(false)

var gr = new GlideRecord('incident');
gr.addActiveQuery();

gr.setWorkflow(false);
gr.query();
data.incidents = [];

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@snowcone 

try to use setWorkflow(false)

var gr = new GlideRecord('incident');
gr.addActiveQuery();

gr.setWorkflow(false);
gr.query();
data.incidents = [];

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

snowcone
Giga Guru

Thank you Ankur Bawiskar!