Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 316607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:23:59+00:00 2026-05-12T08:23:59+00:00

I am writing custom activity for sharepoint workflow and I don’t know how I

  • 0

I am writing custom activity for sharepoint workflow and I don’t know how I can use current workflow item, SPWeb or SPSite.

I see http://blogs.microsoft.co.il/blogs/davidbi/archive/2008/07/21/How-to-get-the-context-item-in-workflow-activity-sharepoint.aspx but xml routines of this solution is too bad for me.

Perhaps there is another code-only solution to get context item in Workflow activity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:23:59+00:00Added an answer on May 12, 2026 at 8:23 am

    The answer to this is a couple steps:

    1. Add the properties to your Custom Activity .cs
    2. Link the properties in your .actions file (so SPD knows how to map to your properties)
    3. Use the properties in your code

    STEP 1: Here is the code for the properties (my class is named GetEmails which you will need to rename to be your class):

    public static DependencyProperty __ContextProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(GetEmails));
    
    [Description("The site context")]
    [Category("User")]
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public WorkflowContext __Context
    {
        get
        {
            return ((WorkflowContext)(base.GetValue(GetEmails.__ContextProperty)));
        }
        set
        {
            base.SetValue(GetEmails.__ContextProperty, value);
        }
    }
    
    public static DependencyProperty __ListIdProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__ListId", typeof(string), typeof(GetEmails));
    
    [ValidationOption(ValidationOption.Required)]
    public string __ListId
    {
        get
        {
            return ((string)(base.GetValue(GetEmails.__ListIdProperty)));
        }
        set
        {
            base.SetValue(GetEmails.__ListIdProperty, value);
        }
    }
    
    public static DependencyProperty __ListItemProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__ListItem", typeof(int), typeof(GetEmails));
    
    [ValidationOption(ValidationOption.Required)]
    public int __ListItem
    {
        get
        {
            return ((int)(base.GetValue(GetEmails.__ListItemProperty)));
        }
        set
        {
            base.SetValue(GetEmails.__ListItemProperty, value);
        }
    }
    
    public static DependencyProperty __ActivationPropertiesProperty = DependencyProperty.Register("__ActivationProperties", typeof(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties), typeof(GetEmails));
    
    [ValidationOption(ValidationOption.Required)]
    public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties __ActivationProperties
    {
        get
        {
            return (Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties)base.GetValue(GetEmails.__ActivationPropertiesProperty);
        }
        set
        {
            base.SetValue(GetEmails.__ActivationPropertiesProperty, value);
        }
    }
    

    STEP 2: Then in your .actions file add to your block the mappings for those properties (note the entries for __ListID, __ListItem, __Context, and __ActivationProperties):

    <Action Name="[DESCRIPTION OF YOUR ACTION]"
      ClassName="[Your.Namespace.Goes.Here].GetEmails"
      Assembly="[yourDLLName], Version=1.0.0.0, Culture=neutral, PublicKeyToken=0bfc6fa4c4aa913b"
      AppliesTo="all"
      Category="[Your Category Goes Here]">
      <RuleDesigner Sentence="[blah blah blah]">
        <FieldBind Field="PeopleFieldName" Text="people field" Id="1"/>
        <FieldBind Field="Output" Text="emailAddress" Id="2" DesignerType="parameterNames" />
      </RuleDesigner>
      <Parameters>
        <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" />
        <Parameter Name="__ListId" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="__ListItem" Type="System.Int32, mscorlib" Direction="In" />
        <Parameter Name="PeopleFieldName" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="Output" Type="System.String, mscorlib" Direction="Out" />
        <Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="Out" />
      </Parameters>
    </Action>
    

    STEP 3:
    Here is an example execute function:

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext provider)
    {
        Output = string.Empty;
    
        try
        {
            SPWeb web = __Context.Web;
            // get all of the information we currently have about the item
            // that this workflow is running on
            Guid listGuid = new Guid(__ListId);
            SPList myList = web.Lists[listGuid];
            SPListItem myItem = myList.GetItemById(__ListItem);
    
            //...
        }
        catch (Exception e)
        {
            //...
        }
    
        return ActivityExecutionStatus.Closed;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a custom channel how can I get the name of the service
Best practices for writing long running custom activities for Workflow Foundation (3.0/3.5) suggest that
When it comes to writing custom MySQL database-driven PHP session management for a VERY
When writing a custom server, what are the best practices or techniques to determine
while writing a custom attribute in C# i was wondering if there are any
I'm writing a custom file selection component. In my UI, first the user clicks
I am writing a custom session handler in PHP and trying to make the
I'm writing a custom swing component (something completely new, but think JTree or JList).
I'm writing a custom MembershipProvider for a legacy database. Users are authenticated by login
I'm writing a custom blog engine and would like to have trackbacks similar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.