GlideFilter.checkRecord with condition builder not matching reference fields

kevin_sherman
Giga Contributor

Hi community,

I'm writing a module that utilizes the condition builder field paired with the GlideFilter API to allow users to define when a certain event triggers. The condition builder + GlideFilter work perfectly if the condition builder is attempting to match on strings, choice fields, bools, etc., but when trying to match on reference fields, it always returns false.

Here's the code. It runs on the task table with a before/update business rule, looking for "checklist definitions" that match.

function getChecklistDefinition () {

      var def = new GlideRecord('u_checklist_def');

      def.addQuery('u_table', current.getRecordClassName());

      def.query();

      while (def.next()) {

              if (GlideFilter.checkRecord(current, def.u_condition)) {

                      return def;

              }

      }

      return false;

}

I know for a fact that I've been able to use GlideFilter.checkRecord with ref fields before in the past, so this is kind of driving me crazy. Any thoughts as to why it's not working now would be greatly appreciated.

Thanks!

Kevin

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

Check the value of 'u_condition' against a 'copy query' of the result you are hoping for in a list.


Long shot: I have found in Fuji that it makes the length of the condition field really short by default and it truncates after save.


Check the 'max length' of the dictionary entry and increase it if necessary.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

3 REPLIES 3

thaddeus_freema
Kilo Explorer

Are you trying to match on string fields?


Using check record String field matches are case sensitive.


The SN Nerd
Giga Sage
Giga Sage

Check the value of 'u_condition' against a 'copy query' of the result you are hoping for in a list.


Long shot: I have found in Fuji that it makes the length of the condition field really short by default and it truncates after save.


Check the 'max length' of the dictionary entry and increase it if necessary.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

You nailed it, Paul. The max length was set to 40 chars. Fuji must have removed that field from the dictionary form, and I hadn't even thought to check.



Wonderful. Thank you so much!