#StackBounty: #caml-query #caml #alert Create list alert with filter on managed metadata field

Bounty: 200

I’m trying to create an alert on a list. The alert should only trigger on a subset of the list items for which a certain managed metadata field has a certain value. So I’m setting the Filter-Property of the AlertCreationInformation to a CAML-query. There is no problem getting the filter to work for say filtering on a choice field using

ClientContext = GetMy365Context(...);
Web web = ctx.Web;
List list = web.Lists.GetByTitle("NotifyTest");
User user = ctx.Web.SiteUsers.GetByEmail("someone@example.com");

AlertCreationInformation aci = new AlertCreationInformation()
    AlertFrequency = AlertFrequency.Immediate,
    AlertType = AlertType.List,
    AlwaysNotify = true,
    EventType = AlertEventType.All,
    DeliveryChannels = AlertDeliveryChannel.Email,
    Title = "Alert filtered on choice",
    User = user,
    AlertTemplateName = "SPAlertTemplateType.GenericList"

aci.List = list;
aci.Filter = "<Query><Eq><FieldRef Name="MyChoiceField" /><Value Type="Text">MyChoiceValue</Value></Eq></Query>";


But, I was unable to find any proper documentation on the supported CAML for Filter. E.g. <In> is not supported as well as Type="Choice"

So my question is, what query can I use to filter on a multivalue managed metadata field?
So far I have tried using the GUID of the term, the lookup id of the term in the taxonomy hidden list, the text-value of the term, the <contains>-operator, the <eq>-operator but without any luck.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.