If both group and filter are used with the record_count operator, it is possible for a count result to be missing for one or more of the groups (because there are no records that meet the filter criteria for those groups). When the result of the record_count is merged back onto the main dataset, the record_count "$id" column will contain NaN values when there is no record count result associated with the group. If the record_count "$id" column is included in the list of Outcome / Output Variables, this causes a 500 - Core Engine returned invalid JSON error in the rules editor.
Example rule: DDF99912 in the test environment
Test data: You can use the DDF00012 negative test data in USDM subfolder of the CORE unitTesting SharePoint
To prevent this error, before returning the result of the operation, you could consider merging the record count results back onto a full list of groups (without filtering) and replace any NaNs with zero (i.e., there were no records for that group). I'm not sure what happens if you use filtering without groups - if there are no records that match the filter, do you get zero or NaN? If NaN is returned it would be better to again replace with zero.
Also, please update the documentation for the record_count operation to:
Use backticks instead of single quotes around the parameter names for consistency with other documentation entries
Include an example of the use of group and filter. I had to go and look at the unit test programs to figure out how to specify a simple (single-variable) filter and I'm not sure how (if it's even possible) to specify a more complex filter. If it's possible to specify more than one variable/value pair in the filter, it would helpful for the documentation to indicate whether these would be combined with "and" or "or".
Correct two occurrences of "values(s)" to "value(s)".
If both
group
andfilter
are used with therecord_count
operator, it is possible for a count result to be missing for one or more of the groups (because there are no records that meet the filter criteria for those groups). When the result of therecord_count
is merged back onto the main dataset, therecord_count
"$id" column will containNaN
values when there is no record count result associated with the group. If therecord_count
"$id" column is included in the list ofOutcome
/Output Variables
, this causes a500 - Core Engine returned invalid JSON
error in the rules editor.Example rule: DDF99912 in the test environment Test data: You can use the DDF00012 negative test data in USDM subfolder of the CORE unitTesting SharePoint
To prevent this error, before returning the result of the operation, you could consider merging the record count results back onto a full list of groups (without filtering) and replace any
NaN
s with zero (i.e., there were no records for that group). I'm not sure what happens if you use filtering without groups - if there are no records that match the filter, do you get zero orNaN
? IfNaN
is returned it would be better to again replace with zero.Also, please update the documentation for the
record_count
operation to:group
andfilter
. I had to go and look at the unit test programs to figure out how to specify a simple (single-variable) filter and I'm not sure how (if it's even possible) to specify a more complex filter. If it's possible to specify more than one variable/value pair in the filter, it would helpful for the documentation to indicate whether these would be combined with "and" or "or".