I have a feature receiver which batch updates a particular field / column in my list. Code is provided below.
NB: This is very simple list item batch processing code which I got from http://msdn.microsoft.com/en-us/library/cc404818(v=office.12).aspx. I do this instead of looping through the entire list because it has 1000s of rows.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
SPList list = web.Lists["MyList"];
SPQuery query = new SPQuery();
query.RowLimit = 100;
do
{
// Get the next batch of 100 uninitialised items.
SPListItemCollection uninitialisedItems = list.GetItems(query);
// Batch update the list items.
StringBuilder methodBuilder = new StringBuilder();
string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<ows:Batch OnError=\"Continue\">{0}</ows:Batch>";
string methodFormat = "<Method ID=\"{0}\">" +
"<SetList>{1}</SetList>" +
"<SetVar Name=\"Cmd\">Save</SetVar>" +
"<SetVar Name=\"ID\">{2}</SetVar>" +
"<SetVar Name=\"urn:schemas-microsoft-com:office:office#MyField\">{4}</SetVar>" +
"</Method>";
for (int i = 0; i < uninitialisedItems.Count; i++)
{
int itemID = uninitialisedItems[i].ID;
methodBuilder.AppendFormat(methodFormat, itemID, list.ID.ToString(), itemID, 1);
}
// THIS IS THE LINE THAT IS CAUSING MY ALERTS TO BE SENT.
list.ParentWeb.ProcessBatchData(string.Format(batchFormat, methodBuilder.ToString()));
query.ListItemCollectionPosition = uninitialisedItems.ListItemCollectionPosition;
} while (query.ListItemCollectionPosition != null);
}
}
The problem here is that an email alert is being sent for every one of my list items saying that it has changed. I want to prevent this alert from being sent as I am merely setting a field that is not made visible to the user. Any idea how to do this?
FYI: I am using MOSS 2007