Task Alert

Jun 15, 2007 at 5:18 AM
Hi to all.
I think that I'm missing something, I have installed the taskalert.wsp, globally deployed and activated for the specific site (site features), but I still don't achieve to make it work. I check all the options and settings for the site and the list without results. I also tried creating a new task list.

Somebody now what could be happening?

Thanks a lot.
Max.
Jun 21, 2007 at 2:26 PM
Do you see anything under the Actions menu for the task list?
Aug 30, 2007 at 9:40 PM
I deployed and activated the Task Alert feature on one of my sites but I can't figure out what it does or how it works. While trying to figure this out I went into the Advanced Properties of the Task list and noticed there was an option to notify user by email when task is assigned. I changed that from NO to YES on one of my task lists and I tested it with success. Thing is, this option is available for all Task lists, even the sites where I didn't active the Task Alert feature. So what does this feature actually do?
Sep 12, 2007 at 1:20 PM
It sets up an alert so that the user is notified when tasks are updated as well.
Sep 15, 2007 at 6:44 PM
Scot, i just read your code for the taskalert because I have been messing with alters and a few items should be done to enhance them. Also, you should use dispose or the automatic dispose (using), since cleaning up after yourself in SharePoint is a good idea. I hate to be critical, the code is still good.

On line 49 of Assigner.cs, the SPWeb elevatedSite = elevatedSiteCollection.OpenWeb(Site.ID) should be wrapped in a using statement at a minimum.

Starting on around line 60, you should use SPFieldUserValue and SPFieldUserValueCollection and not the split string junk, see the example below
This code
char[] delimiter = { ';', '#' };
string[] userValues = UserValue.Split(delimiter);
for (int i = 0; i <= userValues.GetUpperBound(0); i += 4)
{
try
{
SPUser targetUser = elevatedSite.SiteUsers.GetByID(Int32.Parse(userValuesi));

should be replace by something like the below

private void AssignAlert(SPWeb Site, SPList List, SPListItem Item, string UserValue)
{

SPSecurity.RunWithElevatedPrivileges(delegate()
{
string alertType = "List";//Can be "List" or "Item"
string eventType = "All";//Can be "All", "Add", "Modify" or "Delete"
string frequency = "Immediate";//Can be "Immediate", "Daily", or "Weekly"
string confirmation = "true";//Can be "true" or "false"
string logging = "false";//Can be "true" or "false"

//Get the site with elevated permissions
SPSite elevatedSiteCollection = new SPSite(Site.Site.ID);
const string userFieldName = "AssignedTo";
using (SPWeb elevatedSite = elevatedSiteCollection.OpenWeb(Site.ID))
{
if ((item != null) && (itemuserFieldName != null) && (item.FieldsuserFieldName.FieldValueType != null))
{
if (item.FieldsuserFieldName.FieldValueType == typeof(SPFieldUserValue))
{

SPFieldUserValue singleuserVal = new SPFieldUserValue(web, item.FieldsuserFieldName);
if ((singleuserVal!=null) && (singleuserVal.User!=null))
{
//Make a method that does the rest of your
//process (put your code in the below method)
//all of the code after "bool alertExists = false;"
AssignAlertToUser(web, List, Item, singleuserVal.User);
}
}
else
{
if (item.FieldsuserFieldName.FieldValueType == typeof(SPFieldUserValueCollection))
{
SPFieldUserValueCollection userVals = new SPFieldUserValueCollection(web, item.FieldsuserFieldName);
if (userVals != null)
{
foreach (SPFieldUserValue userVal in userVals)
{
if ((userVal != null) && (userVal.User != null))
{
//Make a method that does the rest of your
//process (put your code in the below method)
//all of the code after "bool alertExists = false;"od)
AssignAlertToUser(web, List, Item, userVal.User);
}
}
}
}
}
}
}
});
}
If I am missing something as to why you did it the way you did, I apologize in advance, good luck and keep up the good work.
Sep 19, 2007 at 9:07 PM
It's a community - peer review is essential! Thanks for the input.