Hi,
I have created a custom list. I have a field called manager Email. Whenever a list items gets added to this field manager should get an email. This workflow should be automatic.
Any directions please
Hi,
I have created a custom list. I have a field called manager Email. Whenever a list items gets added to this field manager should get an email. This workflow should be automatic.
Any directions please
"Whenever a list items gets added" sounds like an Event Receiver to me rather than a workflow:
public class MyEventReceiver : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
using (SPWeb web = properties.OpenWeb())
{
SPListItem item = properties.ListItem;
SPUtility.SendEmail(web, true, true, item["ManagerEmail"].ToString(), "Subject", "Body");
}
}
}
EDIT:
You attach this code to a list through a Feature. If you have created a custom list template, you can use the Receivers Element. But if the custom list was created through the UI, you will need to use a Feature Receiver:
public class MyFeatureReceiver : SPFeatureReceiver {
public override void FeatureActivated(SPFeatureReceiverProperties properties) {
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
Type type = typeof(MyEventReceiver);
SPList list = web.Lists["My Custom List"];
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, type.Assembly.FullName, type.FullName);
list.Update();
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) {
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties) {
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties) {
}
}
For more information: