Custom attribute set with custom. but my CQL condition never matches
I write a custom profile attribute from my Vue app like this:
croct.user.edit().set('custom.expertise', 'vue').save();Then I reference it in a CQL condition for an audience, and the audience never matches. The write looks like it succeeds, no error. I am fairly sure I am referencing the attribute name wrong in the query but I cannot see how
2 answers
It is the prefix. Custom attributes are written with the custom. prefix, so your set('custom.expertise', 'vue') is correct. But in CQL you query the same attribute without the prefix. So the condition should reference expertise, not custom.expertise:
user's expertise is "vue"Write with custom., read without it. That asymmetry catches a lot of people.
And the reason it fails silently rather than erroring: undefined variables evaluate to false by design. So when you query custom.expertise in CQL there is no such variable, it resolves to false, and the audience just never matches. No error, no match, exactly what you saw.
Unrelated but worth knowing while you are in there: set attributes like interests merge rather than overwrite when you save, and if the same attribute gets conflicting values the most recent one wins. So repeated saves build up rather than clobber.
Dropped the prefix in the query and it matches now. The silent false explains why I got no error to chase. Cheers