0

How to set up custom field filtering in subscription API

Thijs Senten 4 years ago in API updated 4 years ago 2

I'm reading up on the subscription API and see that it is possible to filter events on custom fields. I seem to be missing part of the picture though, especially with regard to the job_status_changed event. 


How can you automatically set up a custom field with a specific value for filtering on job level? 

- I don't think it's possible to do this in the workflow definitions (for Classic Projects). 

- Setting a default value for a custom field would also make no sense, because they would all be the same and useless for filtering. 

- Setting it manually rather defeats the purpose and is not really error-proof.

- Using a macro + periodic job makes it time-based and therefore also not error-proof.

- Using a project_created event to trigger setting the custom field maybe? That would limit the number of events from 'every job status change' to 'every new project created', so significantly fewer, but it still doesn't feel like a clean solution.


Is there anyone with experience in this who can explain it to me? 

Hi Thijs, 

To make it clear - you'd like to have context-based custom field so you can use that for filtering whenever a new job_status_changed event is sent. Is that right?  

Why do you think the last point on your list is flawed?

Best,

Bartosz

+1

Hi Bartosz,

Based on this part from the documentation, I understand that filtering is recommended and that it's only possible to filter on specific custom fields (but no other fields, such as 'job type' etc.):

Sometimes we are only interested in some of the events. One way is to simply ignore delivered events (in your application), but this may cause unnecessary performance impact. The preferred way is to filter events directly in XTRF and deliver only specific events to your application. Filter is specified during event subscription.
Currently only text and single selection custom fields are supported for filtering. Complex filtering (and, or, not, anyOf, ilike etc.) is not supported.

If that assumption is correct, and I can only filter using those custom fields, there should be an easy way to set those fields to a certain value. The last point on my list seems workable, but it still feels wasteful - it needs another subscription and probably a macro to set a custom field on job level in Classic Projects. Definitely doable, but it feels like a workaround rather than a proper solution. I was hoping someone had a better way to do this.