Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Using GlideRecordSecure

Log in to subscribe to topics and get notified when content changes.

Using GlideRecordSecure

GlideRecordSecure is a class inherited from GlideRecord that performs the same functions as GlideRecord, and also enforces ACLs.

Non-Writable Fields

Be aware that, when using GlideRecordSecure, non-writable fields are set to NULL when trying to write to the database. By default, canCreate() on the column is replaced with canWrite() on the column. If that returns false, the column value is set to NULL.

Checking for NULL Values

If an element cannot be read because an ACL restricts access, a NULL value is created in memory for that record. With GlideRecord, you must explicitly check for any ACLs that might restrict read access to the record. To do so, an if statement such as the following is required to check if the record can be read:
if ( !grs.canRead() ) continue;
With GlideRecordSecure, you do not need to explicitly check for read access using canRead(). Instead, you can use next() by itself to move to the next record. The following example provides a comparison between GlideRecord and GlideRecordSecure.
var count  = 0;
var gr  = new GlideRecord('mytable');
gr. query(); 
while (gr. next()) { 
    if (!gr. canRead()) continue; 
    if (!gr. canWrite()) continue; 
    if (!gr. val. canRead() || !gr. val. canWrite())
        gr. val = null;
        gr. val = "val-" + gr. id; 
    if (gr. update())
        count ++; 
var count  = 0; 
var grs  = new GlideRecordSecure('mytable');
grs. query(); 
while (grs. next()) {
    grs. val = "val-" + grs. id; 
    if (grs. update())
        count ++; 


These are two simple examples using GlideRecordSecure.

var att  = new GlideRecordSecure ('sys_attachment');
att. get('$[sys_attachment.sys_id]'); 
var sm  = GlideSecurityManager.get(); 
var checkMe  = 'record/sys_attachment/delete'; 
var canDelete  = sm.hasRightsTo(checkMe,att);
gs. log('canDelete: ' + canDelete);
var grs = new GlideRecordSecure('task_ci');
var count  = grs. getRowCount(); 
if (count  > 0 ) { 
    var allocation  = parseInt(10000/count) / 100;
    while ( {
      grs.u_allocation = allocation;