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

How to programatically send alert notification to a particular user when a particular field has been changed?

share|improve this question

2 Answers 2

Rather than delve into the dark, twisted and arcane world of SharePoint Alerts, you would probably be better served generating your own email when this happens via an Event Receiver. This would give you total control over the format of the email as well as the ability to add more complex logic, such as notifying other users if other fields change, starting workflows, etc.

It also might be possible to do this via custom workflow but that is not my area of expertise.

share|improve this answer

The dark, twisted and arcane world of Sharepoint Alerts may suit you well, if:

  • You want to send standard sharepoint alert.
  • You don't need to hide some list field data from alert or otherwise modify alert text and style.
  • You are familiar with CAML

If these main conditions are met, you can create SPAlert object from code, with necessary CAML query defined in Filter property. Check out this article for code examples. I may add that in your case, you should define your filter property by comparing old and new values of target field, e.g.

<Query>
    <Neq>
        <FieldRef Name="TargetField/Old" />
        <FieldRef Name="TargetField/New" />
    </Neq>
</Query>

That is SPAlert CAML query for "If TargetField change".

Another way to send a message on item change is a workflow made in sharepoint designer. In workflow there is a Send Email action, from where you can easily set up and modify an email template and recipients. But out of box workflow doesn't know anything about which particular field have been changed.

If you need full control over email message and conditions, then, as Dave suggested, the only option is in using list event receiver and sending custom email message with SPUtility.SendMail method. From code you have more control and can do practically anything but the drawback is that you must do practically everything by yourself - track the field changes, fill alert templates, send emails, etc. If you also need to easily modify the alert template, you will end up creating the full alert templates infrastructure all by yourself and from scratch.

You can combine event receiver way and workflow, by creating specific boolean fields, setting its values in event receiver if your target fields have changed and checking this markers in workflow to send emails properly. Such workaround should give you the flexibility of email alert settings.

share|improve this answer

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.