Create list alert with filter on managed metadata field

%3CLINGO-SUB%20id%3D%22lingo-sub-394544%22%20slang%3D%22en-US%22%3ECreate%20list%20alert%20with%20filter%20on%20managed%20metadata%20field%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-394544%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22votecell%20post-layout--left%22%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%3CDIV%20class%3D%22js-vote-count%20grid--cell%20fc-black-500%20fs-title%20grid%20fd-column%20ai-center%22%3E%3CSPAN%3EI'm%20trying%20to%20create%20an%20alert%20on%20a%20list.%20The%20alert%20should%20only%20trigger%20on%20a%20subset%20of%20the%20list%20items%20for%20which%20a%20certain%20managed%20metadata%20field%20has%20a%20certain%20value.%20So%20I'm%20setting%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EFilter-Property%20of%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EAlertCreationInformation%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eto%20a%20CAML-query.%20There%20is%20no%20problem%20getting%20the%20filter%20to%20work%20for%20say%20filtering%20on%20a%20choice%20field%20using%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%20class%3D%22postcell%20post-layout--right%22%3E%3CDIV%20class%3D%22post-text%22%3E%3CPRE%3E%3CSPAN%20class%3D%22typ%22%3EClientContext%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EGetMy365Context%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(...)%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22typ%22%3EWeb%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20web%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20ctx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EWeb%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22typ%22%3EList%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20list%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20web%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ELists%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetByTitle%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22str%22%3E%22NotifyTest%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22typ%22%3EUser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20user%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20ctx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EWeb%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ESiteUsers%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetByEmail%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22str%22%3E%22someone%40example.com%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ectx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ELoad%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eweb%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ectx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ELoad%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Elist%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ectx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ELoad%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Euser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ectx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EExecuteQuery%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22typ%22%3EAlertCreationInformation%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20aci%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EAlertCreationInformation%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EAlertFrequency%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EAlertFrequency%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EImmediate%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EAlertType%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EAlertType%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EList%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EAlwaysNotify%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Etrue%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EEventType%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EAlertEventType%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAll%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EDeliveryChannels%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EAlertDeliveryChannel%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EEmail%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3ETitle%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22Alert%20filtered%20on%20choice%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EUser%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20user%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EAlertTemplateName%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22SPAlertTemplateType.GenericList%22%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22pun%22%3E%7D%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eaci%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EList%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20list%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eaci%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EFilter%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22%3CQUERY%3E%3CEQ%3E%3CFIELDREF%20name%3D%22%5C%26quot%3BMyChoiceField%5C%26quot%3B%22%3E%3C%2FFIELDREF%3E%3CVALUE%20type%3D%22%5C%26quot%3BText%5C%26quot%3B%22%3EMyChoiceValue%3C%2FVALUE%3E%3C%2FEQ%3E%3C%2FQUERY%3E%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eweb%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAlerts%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EAdd%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eaci%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ectx%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EExecuteQuery%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EBut%2C%20I%20was%20unable%20to%20find%20any%20proper%20documentation%20on%20the%20supported%20CAML%20for%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFilter.%20E.g.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CIN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20not%20supported%20as%20well%20as%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EType%3D%22Choice%22%3C%2FIN%3E%3C%2FP%3E%3CP%3ESo%20my%20question%20is%2C%20what%20query%20can%20I%20use%20to%20filter%20on%20a%20multivalue%20managed%20metadata%20field%3F%20So%20far%20I%20have%20tried%20using%20the%20GUID%20of%20the%20term%2C%20the%20lookup%20id%20of%20the%20term%20in%20the%20taxonomy%20hidden%20list%2C%20the%20text-value%20of%20the%20term%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCONTAINS%3E-operator%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEQ%3E-operator%20but%20without%20any%20luck.%3C%2FEQ%3E%3C%2FCONTAINS%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(also%20posted%20on%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F260488%2Fcreate-list-alert-with-filter-on-managed-metadata-field%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F260488%2Fcreate-list-alert-with-filter-on-managed-metadata-field%3C%2FA%3E)%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-394544%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor
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-metad...)

0 Replies