Post

7 followers Follow
1
Avatar

Filter on empty field

I would like to filter items with an empty value on a specific field, but I receive an error. How do I filter these items?

I tried:

$app = PodioItem::filter($app_id, array('filters' => array($FieldThatMustBeEmpty => '')));

Array400/item/app/2779441/filter/Invalid value u'' (string): Must not be empty

$app = PodioItem::filter($app_id, array('filters' => array($FieldThatMustBeEmpty => NULL)));

Array400/item/app/2779441/filter/Invalid value None (null): must be non empty string

Stephan Vierkant Answered

Please sign in to leave a comment.

9 comments

0
Avatar

Hi Stephan,

What is the field type you are filtering on? Not all field types accept null. As you can read on https://developers.podio.com/doc/filters only category, app, contact and question fields will filter on null.

All the best,

Andreas 

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

You cannot filter on text fields. You can see the list of fields you can use for filtering on the link in my previous comment. You can use the search interface for text fields, but it will also not allow you to search for the null value. If the app does not contain an excessive amount of items you can simply pull all the items in the app and do the filtering yourself.

All the best,

Andreas 

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Pulling all items is not a great option: there are 15.000+ items. Why is filtering on text fields not possible? When I try, the API already returns the total amount of filtered items.

Stephan Vierkant 0 votes
Comment actions Permalink
0
Avatar

Filtering on text fields is not possible for performance reasons. As I mentioned above you can use the search interface to search a specific app. This will among other things search text fields. Read more about it here https://developers.podio.com/doc/search -- it's a pretty powerful tool.

/Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Hi Guys

Just following up on this thread... i'm trying to build a filter that shows me all items that have a null (or blank) value in a date field? I can't for the life of me work out how i should do this? Any ideas would be greatly appreciated!

thnx so much

 

ciao 

 

nunz

Nunzio Gambale 0 votes
Comment actions Permalink
0
Avatar

Hi Nunzio,

As I mentioned in the first comment in this thread only category, app, contact and question fields will filter on null. We don't support filtering for null values on date fields at the moment.

All the best,

Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
3
Avatar

It would be SO useful to filter on a null date field! And surely not difficult to code? Any chance please?
Thanks,
Matt

Matt Clifton 3 votes
Comment actions Permalink
2
Avatar

Old thread I see, but I recently was looking to do this and found a solution that worked for myself.

I needed to filter based on empty an Number Field. One which recorded the estimate # and invoice # in QuickBooks. So I created a Calculation Field, which just checks for null through a series of if statements.

  • 0 - Both fields are empty
  • 1 - Estimate is filled, Invoice is empty
  • 2 - Estimate is filled, Invoice is filled

There's probably a dozen ways to write this and I'm not the best at these logical calculations, but this is how I did it and was able to accomplish what I wanted.

Then to create the views I wanted in my Projects App, I filtered by this new field, based on number ranges. The following is for items that do not have an estimate entered (if they are in the estimating category):

And the following is for items that do not have an invoice entered (if they are in the invoicing category):

Hope this helps all future searchers looking to accomplish something like this.

Derek Highet 2 votes
Comment actions Permalink