Singular expression refers to non-unique object.

This is a really great question, and one in which everyone writing relevance will eventually hit.

BigFix Relevance has 2 forms, Singular and Plural.

Singular Relevance MUST have exactly 1 result. 0 results is an error, 2 or more results is an error.

Plural Relevance is “valid” no matter how many results it has, no hard errors should generally be thrown by plural relevance, with some exceptions. This means there can be 0 results, or 1 result, or 2+ results, and all options are equally fine as far as the “validity” of the relevance is concerned.

So in your case, the error Singular expression refers to non-unique object. means that your relevance is written such that there must be exactly 1 result, but there is in-fact NOT exactly 1 result. In this particular case, since it is showing 1 result before throwing this error, then that means there are 2 or more results.

This is why I recommend that ALL relevance is written to be plural. BUT if you follow this advice, then you will eventually run into the opposite problem, the error: A singular expression is required.

See this example:

16 PM

If we wanted to know if there was at least 1 result which was 0 we can’t directly compare 2 different numbers to a single number, because this doesn’t make sense, we would instead do this:

30 PM

In this case, we are filtering all results down to only those which are 0, then doing the comparison.

The longer version is basically, always write plural relevance, unless it is within a clause surrounded by parenthesis like … whose( ) or ( ) of … Example: Plural to Singular? Formatting options? Unique? Help? - #5 by jgstew

So the real question is, how do we rewrite your relevance, such that it can always be plural?

  1. Reorder the flow of relevance to be Right to Left as much as possible
  2. Pluralize all of the relevance
  3. IF/THEN/ELSE actually becomes unnecessary and is inefficient, so remove that

This should be the final result:

(it as trimmed string & " - BigFix Checked it on " & preceding text of last " " of following text of first " " of (now as string) ) of preceding texts of firsts " " of substrings after "=%22" of lines 418 of files whose((it starts with "esp_processing_data" AND it contains ".xml") of (name of it as lowercase)) of folders "C:\postilion\eSocket.POS\incoming"

This relevance should be faster to execute, plus handle multiple results, instead of just a singular result. ALSO in the case in which there are 0 results, it will report <none> instead of throwing an error, but it also won’t return the helpful message MID Unknown. It is actually most efficient to just report <none>, but if you REALLY want to return MID Unknown then it is possible to add that back in a few different ways, but I won’t go into that right this second unless it is a “must”.

Related:

2 Likes