SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created an custom workflow activity with the following code:

namespace Custom.SharePoint
    public class CustomActivity : Activity
        #region Fields
        public static readonly DependencyProperty __ContextProperty =
            DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(WebServiceActivity));

        public static readonly DependencyProperty AddressProperty =
            DependencyProperty.Register("Address", typeof(string), typeof(WebServiceActivity));

        public static readonly DependencyProperty StatusIdProperty =
            DependencyProperty.Register("StatusId", typeof(string), typeof(WebServiceActivity));

        #region Properties
        public WorkflowContext __Context
            get { return (WorkflowContext)GetValue(__ContextProperty); }
            set { SetValue(__ContextProperty, value); }

        public string Address
            get { return (string)GetValue(AddressProperty); }
            set { SetValue(AddressProperty, value); }

        public string StatusId
            get { return (string)GetValue(StatusIdProperty); }
            set { SetValue(StatusIdProperty, value); }


        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
                var listItem = this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl);
                var requestId = listItem["RequestId"];

                // rest of code removed for brevity
            return ActivityExecutionStatus.Closed;

Unfortunately, this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl) always returns null, even though this.__Context.CurrentItemUrl has a valid value (e.g. "http://{Server Name}/Lists/{List Name}/DispForm.aspx?ID=9")

Am I doing something wrong?

share|improve this question
up vote 1 down vote accepted

I have never had luck using SPWeb.GetListItem...I've used the following in the past when dealing with WorkflowContext objects:

SPListItem item = __Context.Web.Lists[new Guid(__Context.ListId)].GetItemById(__Context.ItemId);

Should do the trick.

share|improve this answer
+1, that is how I do it too:… – Kit Menke Aug 4 '11 at 19:07

Your Answer


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.