Forum Discussion

Benjamin Schowe's avatar
Benjamin Schowe
Copper Contributor
Apr 04, 2019

Create list alert with filter on managed metadata field

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");ctx.Load(web);ctx.Load(list);ctx.Load(user);ctx.ExecuteQuery();

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>";
web.Alerts.Add(aci);
ctx.ExecuteQuery();

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.

 

(also posted on https://sharepoint.stackexchange.com/questions/260488/create-list-alert-with-filter-on-managed-metadata-field)

No RepliesBe the first to reply

Resources