Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I working with custom AlertTemplate. I only want to send an Alert if field "Beställare" or "Agent" contains my UserId I Have tried with this query, but I always get an Alert when something chanches.

    <Query>
  <And>
   <Or>
    <Eq>
        <Value type="integer"><UserID /></Value>
        <FieldRef name="Best%5Fx00e4%5Fllare/New"/>
    </Eq>
    <Eq>
        <Value type="integer"><UserID /></Value>
        <FieldRef name="Agent/New"/>
    </Eq>
   </Or>
  </And>
 </Query>

How will I change by query so I only get alerts for the conditions above?

share|improve this question

1 Answer 1

Using the <UserID> element like you've done is absolutely right. Compare your CAML to the official MSDN example here -- perhaps try placing your <Value> node below the <FieldRef> nodes as they have done. Everything else looks okay.

Alternatively, any time you create a new alert template you will need to do these three things before your changes will take effect:

  • Load your your custom alert template XML into SharePoint with the updatealerttemplates STSADM command

  • Associate you new alert template with your list as follows:

    SPAlertTemplateCollection alertTemplates = new SPAlertTemplateCollection((SPWebService)(SPContext.Current.Site.WebApplication.Parent)); 
    list.AlertTemplate = alertTemplates["Your Template Name"];
    list.Update();
    
  • Restart IIS (sometimes you may need to restart "SharePoint 2010 Timer" service too)

share|improve this answer
    
I get the same result when I try to change order and restart the iis ans the service. The other things I have done before. –  Daniel Jan 19 '12 at 10:24
    
If you've followed all the steps above, then the only room for error are the <FieldRef> attributes in your CAML. Try this... 1) query only the "Agent" field (the special characters in your other field name may be causing errors). 2) Remove "/New" from the field name, and 3) add LookupId="True" to the <FieldRef> tag. See the official FieldRef Element definition (make sure you read then comments at the bottom re: the LookupId property) –  Nick Larter Jan 20 '12 at 3:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.