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

  • SEARCH
  • Home
  • 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 8353653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:19:30+00:00 2026-06-09T09:19:30+00:00

Scenario: User clicks a command on the workflow Workflow custom action carry out a

  • 0

Scenario:

  • User clicks a command on the workflow
  • Workflow custom action carry out a number of checks
  • Workflow custom action executes another command on the same workflow dependant on results

The code I have so far is:

Database db = Factory.GetDatabase("master");
if (Request.QueryString["_id"] != null)
{
  var itm = db.GetItem(new ID(Request.QueryString["_id"]));
  WorkflowCommand[] availableCommands = wf.GetCommands(itm.Fields["__Workflow state"].Value);   
  wf.Execute(Request.QueryString["command"], itm, "Testing working flow new screens", false, new object[] { }); // Execute the workflow step.
}

However, I get a Object not set to an instance error on the wf.Execute line – but with no meaningful stack trace or anything 🙁

I’ve put in the wf.GetCommands line just to check that things are actually where I expect them, and availableCommands is populated with a nice list of commands that exist.

I’ve checked the commandId is valid, and exists.

Itm is not null, and is the Content Item that the workflow is associated to (that I want the workflow to run in context with).

I’ve checked that the user context etc is valid, and there are no permission issues.

The only difference is that I am running this code within an .aspx page that is executing within sitecore – hopeever, I wouldn’t have expected this to cause a problem unless there is a context item that isn’t being set properly.

  • 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-06-09T09:19:31+00:00Added an answer on June 9, 2026 at 9:19 am

    Workflow needs to be run within a SiteContext that has a ContentDatabase and workflow enabled. The easiest way to do this within your site is to use a SiteContextSwitcher to change to the “shell” site.

    using (new SiteContextSwitcher(SiteContextFactory.GetSiteContext("shell")))
    {
        wf.Execute(Request.QueryString["command"], itm, "Testing working flow new screens", false, new object[] { }); // Execute the workflow step.
    }
    

    An example of this can be found within the code for the WeBlog Sitecore module.

    http://svn.sitecore.net/WeBlog/Trunk/Website/Pipelines/CreateComment/WorkflowSubmit.cs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario: in activity A, when a user clicks a button,
Problem - user clicks do something button (view), view model receives command and passes
what is the best practice for this scenario: 1) User clicks Sort huge javascript
I have the following scenario: A user on one our customer's website clicks a
My scenario is to load only 7 items initially and when user clicks Next
In this scenario: User enters some information into a textbox User clicks a button
This is the scenario: The user clicks on e.g. a button, that loads (using
We are generating Sales Report using Hibernate. Scenario When user clicks on generate report
I have a scenario where the user clicks on a UIButton and the event
Scenario: User clicks on item. Following code runs and opens a modal with a

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.