[Rt-commit] rt branch, 5.0/rest2-query-by-json-support-custom-fields, repushed
Craig Kaiser
craig at bestpractical.com
Thu Mar 4 17:50:56 EST 2021
The branch 5.0/rest2-query-by-json-support-custom-fields was deleted and repushed:
was 89424af10b8cf74ee6d46bfc6aad13acc3abb190
now 0a301a7ddc17905947c63ec071cd46377f9970ed
1: 9a4672d14a ! 1: b6c95d173c Add support for custom fields in REST2 JSON query
@@ -20,33 +20,20 @@
- FIELD => $limit->{field},
- VALUE => $limit->{value},
- ( $limit->{operator}
-+ next unless ( $limit->{field} || $limit->{'CustomField'} ) && defined $limit->{value};
++ next unless $limit->{field} && defined $limit->{value};
+
-+ if ( $limit->{field} ) {
-+ next unless $searchable{$limit->{field}};
-+
-+ $collection->Limit(
-+ FIELD => $limit->{field},
-+ VALUE => $limit->{value},
-+ ( $limit->{operator}
-+ ? (OPERATOR => $limit->{operator})
-+ : () ),
-+ CASESENSITIVE => ($limit->{case_sensitive} || 0),
-+ ( $limit->{entry_aggregator}
-+ ? (ENTRYAGGREGATOR => $limit->{entry_aggregator})
-+ : () ),
-+ );
-+ }
-+ elsif ( $limit->{'CustomField'} ) {
++ if ( $limit->{field} =~ /CustomField\.\{(.*)\}/ ) {
++ my $cf_name = $1;
++ next unless $cf_name;
+
+ my ($ret, $msg) = $custom_field_object->LoadByName(
-+ Name => "$limit->{'CustomField'}",
++ Name => $cf_name,
+ LookupType => $collection->RecordClass->CustomFieldLookupType,
+ IncludeGlobal => 1
+ );
+
+ unless ( $ret && $custom_field_object->Id ) {
-+ RT::Logger->error( "Could not load custom field: $limit->{'CustomField'}: $msg" );
++ RT::Logger->error( "Could not load custom field: $limit->{'field'}: $msg" );
+ next;
+ }
+
@@ -63,6 +50,21 @@
- );
+ );
+ }
++ else {
++ next unless $searchable{$limit->{field}};
++
++ $collection->Limit(
++ FIELD => $limit->{field},
++ VALUE => $limit->{value},
++ ( $limit->{operator}
++ ? (OPERATOR => $limit->{operator})
++ : () ),
++ CASESENSITIVE => ($limit->{case_sensitive} || 0),
++ ( $limit->{entry_aggregator}
++ ? (ENTRYAGGREGATOR => $limit->{entry_aggregator})
++ : () ),
++ );
++ }
}
-
- my @orderby_cols;
2: 3890d94a8f ! 2: c5f8a204e1 Add test for searching users custom fields with REST2
@@ -33,7 +33,7 @@
+
+ my $payload = [
+ {
-+ "CustomField" => "Department",
++ "field" => "CustomField.{Department}",
+ "value" => "HR",
+ "operator" => "="
+ }
3: 89424af10b ! 3: 0a301a7ddc Add test for searching groups based on custom fields with REST2
@@ -48,7 +48,7 @@
+
+ my $payload = [
+ {
-+ "CustomField" => "Group Type",
++ "field" => "CustomField.{Group Type}",
+ "value" => "Test",
+ }
+ ];
More information about the rt-commit
mailing list