Grouping/filtering/reporting on calculated true/false field

CezaryBasta
Tera Guru

Hi,

Here's a scenario:

  1. A calculated true/false field on incident table with a simple code (Category empty😞
    (function calculatedFieldValue(current) {     return current.getValue('category') == '' || current.getValue('category') === null || current.getValue('category') == null; })(current);
  2. A list of incident with grouping on new field enabled:
    find_real_file.png

  3. An xml view of INC0000048 from the list above shows correctly <u_category_empty>true</u_category_empty>
  4. A simple backgorund script shows 0 rows returned:
    var test = new GlideRecord('incident'); test.addEncodedQuery('u_category_empty=true^u_category_empty=\'true\''); test.query(); gs.log(test.getRowCount());

Question: why my Category empty = true records are inside false results group? I am also unable to filter on either true or false on this field.

This happens on both Istanbul and Jakarta fresh developer instances.

--
See more of my content here.
1 ACCEPTED SOLUTION

Rama Chandra D
Kilo Guru

I think 'calculated value' is not a good choice, if you already have a lot of record. Even though the list view show's   true or false, they might not actual be on the table.You need to save the records for the value to be written to the table. I suggest to run a BR on insert, so your new incidents would have the field value populated. For the existing ones use a Schedule job and set the value based on your criteria.



Darshak


View solution in original post

4 REPLIES 4

Rama Chandra D
Kilo Guru

Hi,



Can you explain, why do you have the query set up as, 'u_category_empty=\'true\'' ? What does this syntax accomplish?



Darshak


Sharique Azim
Mega Sage

Hi Cezaty,



Please note if a check box is not chosen,or if 'none' is chosen in choice field with default as none, then for those values where there is no value selected => is considered as false value.


Rama Chandra D
Kilo Guru

I think 'calculated value' is not a good choice, if you already have a lot of record. Even though the list view show's   true or false, they might not actual be on the table.You need to save the records for the value to be written to the table. I suggest to run a BR on insert, so your new incidents would have the field value populated. For the existing ones use a Schedule job and set the value based on your criteria.



Darshak


Yes, that would probably work, thanks.


--
See more of my content here.