The CreatorCon Call for Content is officially open! Get started here.

addQuery on a document type field

davidgustafsson
Tera Expert

Hi

I am trying to write a condition argument for a scheduled job. The issue I am having is that it is ignoring the lines about instance.state. Is there really no possibility to use the instance field (of document type) for a addQuery condition? I mean we do have the table in another field so the information is there.

 

var ga = new GlideAggregate('sys_email');
ga.addAggregate('COUNT');

var qc1 = ga.addQuery('u_anonymisation_date','>','javascript:gs.endOfToday()');
qc1.addOrCondition('u_anonymisation_date',"");
var qc2 = ga.addQuery('instance.state','rejected'); //not working
qc2.addOrCondition('instance.state','closed'); //not working
qc2.addOrCondition('instance.state','cancelled'); //not working
var qc3 = ga.addQuery('sys_id','a90768c84f7c5700eba9fcb28110c7af');
ga.query();
ga.next();
ga.getAggregate('COUNT') !== '0';

1 ACCEPTED SOLUTION

johnnyd54
Giga Expert

It's always been my understanding that you can't dot-walk document ID's, only reference fields. You would have to pass the documentID value into a different gliderecord query on the incident table to find the state

View solution in original post

2 REPLIES 2

johnnyd54
Giga Expert

It's always been my understanding that you can't dot-walk document ID's, only reference fields. You would have to pass the documentID value into a different gliderecord query on the incident table to find the state

Even though I think this is strange as the info is there and ServiceNow obviously is using the field as a relation to the object it is pointing to I guess I have to accept that this "bug" is there in the setup.

So then I will try with another approach. Add a business rule on task that will mark emails related to the task as "task closed" on the email and then use that field instead.