How to query a MultiSelect drop-down custom field that has no value

Document ID : KB000074852
Last Modified Date : 27/03/2018
Show Technical Document Details
Question:
Normally multi-select drop-down fields have at least one value selected. It may be worthwhile to know how to query if a multi-valued drop-down field has no value selected. This is allowed unless that field is mandatory. This applies to both out-of-box as well as custom fields of that type.
Answer:
In this example we created a custom field named: "c_SagiTestMultiValued". We associated it with the Defect artifact. We have a many defects in our project and we'd like to query only those defect without any selected value for this attribute.

For the Defect artifact look at the fields:
User-added image

And find that multi-valued attribute:
User-added image

You can view/edit the details and see the list of values it may have:
User-added image

You may have projects in place that already use our WSAPI or SDK. However, one of the easier ways to try out query strings
and confirm they work is our WSAPI online doc. You bring that up and click on the artifact that has this attribute (in this case Defect). Then, scroll down the list of attributes to find it.

You can see the actual name of this attribute is "c_SagiTestMultiValued" (notice the prefix 'c_' which is used for custom fields). This is the name you must use in your query string. You can not use the name we saw earlier in the list of fields or the display name,

Notice the Query Expression Operators in this table, they indicate the operators you can use when querying this attribute. As you can see the "=" operator is not applicable for a multi-valued attribute, and hence you shall need to use "contains": 
User-added image

Back on the Defect artifact enter the Query String, in this case it is: (c_SagiTestMultiVaued contains "")  
This would be the query to use to retrieve the Defects without values in this attribute:
User-added image

Clicking the 'Query' button you will result in this pop-up window where you can see the total number of Defects matching this query, in this example that number is 6. Lower you can find more information about these defects:
User-added image