I'm trying to search all community users to get a list of people who do not have a custom attribute set.
Using the query StringCriterion, is there a way to match against null rather than a value?
I've tried the following code, but it doesn't work.
private static UserCollection GetAllUsersWithNoCode()
{
UserQuery query = new UserQuery();
StringCriterion criterion = new StringCriterion();
criterion.Value = null;
query[AttributeNames.CommunityUser.AUTO_LOGIN_TOKEN] = criterion;
return CommunitySystem.CurrentContext.DefaultSecurity.GetQueryResult(query);
}
Thanks in advance for anyone who can help...
Just had a reply back from Episerver support. They state that it's not possible to query custom attributes this way. The solution is to manually add rows to the DB (for all users) with empty strings and then use the string.empty value to find the results.
Not quite the answer I was hoping for, but I'll test and update with results later...