开发者

sharepoint workflow

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 auto开发者_开发问答matic.

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:

  • How to: Create an Event Handler Feature
  • Feature Events
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜