Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

How to check whether the filter conditions are met when use gliderecord to assign a value to reference a field

panda1
Kilo Guru

For referencefields, reference qual are used,Records that do not meet the conditions cannot be selected on the UI

But use glideRecord.setValue(record'sys_id);

The record does not meet the filtering conditions,But his value is still normally set

I want to judge whether the record meets the filtering conditions before setValue. What should I do

I got this value from reference qual: (javascript: "parent=" + new ......)

Can i use such a script in gliderecord to filter record

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

You need to glide same table with reference qualifier condition query.

And check if your sys_id is one of the them.

to do that you have to apply query like below:

var grRec = new GlideRecord('tablename');
grRec.addEncodedQuery('Reference qualifier condition here'); // 'parent=somevalue^active=true'
grRec.addQuery('sys_id',record'sys_id); // this is to check if record is matching reference qualifier
grRec.query();
if(grRec.hasNext()){
glideRecord.setValue(record'sys_id);
}

 

 

Thanks,

Anil Lande

View solution in original post

2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

You need to glide same table with reference qualifier condition query.

And check if your sys_id is one of the them.

to do that you have to apply query like below:

var grRec = new GlideRecord('tablename');
grRec.addEncodedQuery('Reference qualifier condition here'); // 'parent=somevalue^active=true'
grRec.addQuery('sys_id',record'sys_id); // this is to check if record is matching reference qualifier
grRec.query();
if(grRec.hasNext()){
glideRecord.setValue(record'sys_id);
}

 

 

Thanks,

Anil Lande

Ankur Bawiskar
Tera Patron

Hi,

yes while using GlideRecord it doesn't respect the ref qualifier.

In order to check if the record matches the filter you need to query and check if the query returns any result

you can use GlideFilter to check this

Regards
Ankur