Session Relevance: Filtering Results based on MIME Fields

I’m doing some custom work through the API and session relevance to track our content as it changes using custom MIME fields. However, I’m having problems filtering my session relevance queries.

This works:

((if exists (mime fields “x-content-status” of it) then (mime fields “x-content-status” of it) else (“”)), name of it) of bes fixlets whose (name of site of it contains “API”)

This also works:

((if exists (mime fields “x-content-status” of it) then (mime fields “x-content-status” of it) else (“”)), name of it) of bes fixlets whose ((name of it contains “KEN”) AND (name of site of it contains “API”))

However this does not, most likely due to the embedded if exists in the whose clause. But I do not know how else to write it.

((if exists (mime fields “x-content-status” of it) then (mime fields “x-content-status” of it) else (“”)), name of it) of bes fixlets whose (((if exists (mime fields “x-content-status” of it) then (mime fields “x-content-status” of it) else (“”)) contains “Ready”) AND (name of site of it contains “API”))

Any suggestions on how to construct my session relevance? I’m generating it dynamically, so “Ready” could be several different values or a null value, so that all results are returned.

Thank you!
-Ken

It looks like you have a good plan, and the syntax is close; I’m on a phone now and can’t actually check, but your query looks like it should work. I think we could simplify though by using the pipe operator " | ". This is an error handler - if the expression on the left generates an error (such as “Singular Expression refers to nonexistent object” for a missing mime field), then the expression on the right is substituted instead of throwing an error.

Give a try to

(mime field “x-content-status” of it | "none")

Note I switched to the singular “mime field” so a missing field would throw an error, which will be handled by the pipe.

1 Like

Even if this isn’t perhaps the most efficient way, I believe this should work (I’ve not tested this):

(values whose (it contains "Ready") of mime fields whose (name of it = "x-content-status") of it, name of it) of bes fixlets whose (exists mime field "x-content-status" of it)