Welcome to MSDN Blogs Sign in | Join | Help

What About Workflow and ASPX Forms?

Hi everyone, 

I’ve gotten a lot of questions about using aspx forms in workflow, so I wanted to talk about them a bit here and hopefully address some of the questions you have.  To prevent boring you to death;), I will try keep this pretty high level and short.  I’d recommend reading and understanding my post on forms first, as I'll gloss over some concepts from there.   Here we go!

One Form Understanding to Rule Them All

Aspx form solutions are not that different from InfoPath (IP) solutions.  IP forms are just special out-of-box aspx pages with an IP UI.  Aspx forms are just custom aspx pages with aspx UI.  That word “custom” instead of “out-of-box” is really all the difference.

Aspx forms are just one level of abstraction lower, so if you understand how data flows from an IP form into a workflow, then you’ll understand what your aspx page needs to do.  So what do you do differently when using aspx instead of IP?  Perhaps this would be better illustrated with a couple pictures.

The following diagram shows how data flows from an IP solution into the workflow (swiped this from the my blog series doc;)). Stuff you need to implement is circled in red.  Data flows from the form to the host aspx page, which calls a special SharePoint function to talk to the workflow.  This aspx page is provided out-of-box, so all you have to implement is the UI (the InfoPath form):

With aspx forms, this flow diagram is exactly the same.  As with the IP case, you need to implement the UI (this time using aspx controls instead of IP).  But there’s one more step this time: you also need to implement the aspx page code-behind to call the workflow function and redirect (which was already provided for you for the IP case).  So in summary, the differences between aspx forms and IP forms are that for aspx forms:

a)      You’re using aspx controls instead of an IP controls, and

b)      You, the developer, have to implement the page that calls the special SharePoint workflow function and redirect to another page(rather than having this done for you out-of-the-box)

So it’s just one more step for aspx forms, as shown in this diagram:

 

Ok…So How Do You Implement an Aspx Form?

So enough with the theory, you say.  What do I have to do to create an aspx workflow form?  Well, hopefully if the theory makes sense, you will see that the two things you need to do are:

1)      Create the UI (using aspx controls)

2)      Write code in the cs file to call the workflow function and redirect to another page

I won’t go into (1) because it’s just standard aspx page implementation.  If you’re familiar with the technology, you can add controls and collect the data in the same way you would any non-workflow page.:)  You can do anything you want to the page in terms of behavior and validation that you would ordinarily do. 

Item (2) is the only thing that’s really specific to workflow.  When the user clicks the submit button, you just need to make one of the calls in the table in the forms post:

Association - SPWorkflowAssociation::CreateListAssociation(… associationData)

Then add the association to list or content type using SPList.AddWorkflowAssociation(association...)

Initiation - SPWorkflowManager.StartWorkflow(association, web, list)

Task - SPWorkflowTask.AlterTask(...)

Modification - SPWorkflowManager.ModifyWorkflow(...)

 

The data you pass in as parameters for these calls can be collected from the user, or you can use other SharePoint OM functions and page parameters to get this information.  After you’re done calling the workflow, you can do whatever you want, such as redirecting to a page of choice.

And that’s itJ.  While it may seem complex at first glance, at the heart of it, creating aspx forms is really just a matter creating an aspx form that makes a special workflow call. 

 

That Was Easy…Too Easy…

Now, of course, I’m over-simplifying a bit.  Setting this up is not a walk in the park (What's all that code in the Aspx Collect Feedback sample?).  There’s still some auxiliary work that needs to be done, such as gathering parameters for the call and making the form data string that’s passed into the function “parse-able” by the workflow (e.g. making a serializable class for the data).  And of course, you still need to write the general non-workflow-specific code.  

But for any workflow, it’s essentially the same thing every time.  People have asked me why there aren’t more aspx samples than Aspx Collect Feedback, and a large part of it is that there’s not much more to show.  The workflow calls you make are the same for every workflow; the only difference is the data you collect and how you serialize it into the workflow call.  Once you understand the concepts behind them, you can use the sample pages for reference, change the UI, and tweak the code and data binding for your custom form. 

In any case, I think the biggest hurdle to get over for aspx workflows is a conceptual one, so if you use aspx pages, just remember: it’s just a normal aspx page with a workflow call; be smooth and be cool.

 

I hope this helps!  Good luck!

-Eilene

Published Tuesday, December 19, 2006 2:00 PM by sptblog
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: What About Workflow and ASPX Forms?

That may be easy for a person who knows how to author both ASPX and IP forms, but given to a person who's never written code, it's way too complex.  Give them InfoPath and it isn't.

I've taught several non-IT people InfoPath forms at my company and now they are extremely vital to our line of business.  Prior to InfoPath, we had Word/Excel forms that were published on our Intranet.  The entire Save As... to your Desktop, attach to email, etc is gone.  Open InfoPath, fill out form, click submit and you're done has saved us a great deal of time.

Tuesday, December 19, 2006 11:06 AM by TheODogg

# re: What About Workflow and ASPX Forms?

hi:

  i want to know when a workflow intance is running ,it use which user?

                                    tks

Tuesday, December 26, 2006 4:09 AM by zealylee

# re: What About Workflow and ASPX Forms?

When can we expect the 40 new templates? I haven't been able to find a release date yet?

Thursday, December 28, 2006 11:36 AM by David Mackey

# Workflow e form ASPX

Qualche informazione utile dal team di SharePoint sulla definizione di form ASPX per la gestione dei...

Sunday, December 31, 2006 10:05 AM by Paolo Pialorsi

# re: What About Workflow and ASPX Forms?

Any idea when the SDKs will be released? We were expecting them in late Novemeber but they don't seem to have showed up so far...

Tuesday, January 02, 2007 8:06 AM by Nick

# re: What About Workflow and ASPX Forms?

To anyone working at Microsoft:

When will Sharepoint documentation appear in MSDN?

It's been over a month and a half since Sharepoint 3.0 was released, and there's still almost no documenation.

This isn't beta anymore.  My boss wants functional workflows, and I'm still digging through sample code to trying to figure out what the heck Sharepoint is expecting me to use for a correlation token.  Why?  Because all of the ExternalDataExchange services are undocumented.  It makes me look bad.  It makes Sharepoint look bad.

When will Delay activities work in Sharepoint?  "Real world" workflows will never be possible if Delays aren't going to return reliably.  Most business processes need some sort of guarantee that they won't just run forever.

Where is the SDK?

Developers are fumbling around in the dark on this stuff.

Tuesday, January 02, 2007 4:44 PM by Daryl

# re: What About Workflow and ASPX Forms?

Thanks Eilene, that's really useful! While Infopath is going to be great for simple forms, there are going to be cases where the customer wants a form that is just too complex for it - and so knowing how to create it in ASPX will be useful.

I do have to agree with Daryl though - when will Delays be fixed?

Wednesday, January 03, 2007 4:01 AM by Andy Burns

# re: What About Workflow and ASPX Forms?

the collect feedback sample is near to what I have to do but I need to add one more feature:

the possibility when modifying a task to add another reviewer from the task page directly...

how can i do that?

in the example something similar is done using workflow modification..but that's not applicable to what i've described here above

Daryl is right

we are missing some good documentation and samples that make WSS 3.0 far from being usable from a developer point of view

Thursday, January 04, 2007 11:05 AM by Vigj

# re: What About Workflow and ASPX Forms?

Hi guys,

Sorry for the late response, but I wanted to make sure I could tell you something more substantial:).  Thanks for your patience!

The SDK's are now live on MSDN (http://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en for MOSS, http://www.microsoft.com/downloads/details.aspx?familyid=05e0dd12-8394-402b-8936-a07fe8afaffd&displaylang=en for WSS.  

The Delay hotfix is now available via Product Support Services.  Please call PSS and ask for the hotfix for KB#929816.

As for adding a reviewer when a task is created, you can do a number of things.  1) in your OnTaskChanged handler code, use the same code you used in your modification to add a new reviewer, 2) call ModifyWorkflow in your aspx page before you call AlterTask.  The oob workflows do the former when you say reassign task.

-Eilene

Tuesday, January 23, 2007 1:06 PM by Eilene Hao

# re: What About Workflow and ASPX Forms?

Hi Eilene!

I have been using the ASPXCollectFeedback example as a basis of my custom workflow.

What I realy need to know is what is the best way to create/edit the .aspx form itself? When trying to modify the ones in the example you just can't get it validated or displayed in the designer as it is missing the referenced masterpage, and many of the other assembly references in the asp-code report a failure in resolving.

Despite this, the example compiles and runs fine on my WSS site. I just feel I lack the tools to edit/create these forms in a good way.

A fast reply would be greatly appreaciated! Have a nice day :-)

-Woody

Friday, January 26, 2007 4:57 AM by Woody

# New Office Visual How Tos and Office Developer How To Center

A "Visual How To" is a new content type that combines some of the best elements of blogs, video, and technical articles by providing a brief (1-3 page) page of content. The idea is that developers have 2 minutes, 5 minutes, or 15 minutes to spend on a

Tuesday, January 30, 2007 8:11 PM by Erika Ehrli

# re: What About Workflow and ASPX Forms?

Eilene,

Thanks for the posts these have been very helpful.

I am wondering what the disadvantages of using InfoPath forms are.  Is it true that the users interacting with the workflow would need InfoPath installed?

Regards,

Greg

Tuesday, January 30, 2007 10:59 PM by Greg

# re: What About Workflow and ASPX Forms?

In reply to your post Greg,

No, the users would not need InfoPath installed when interacting with a workflow that uses InfoPath forms. There is an engine built into SharePoint Server 2007 (MOSS) which hosts these forms in the browser.

However, if you are only using SharePoint services (WSS 3.0) and not the Server (MOSS), you can't use InfoPath forms at all and must use aspx forms.

-Woody

Tuesday, February 06, 2007 2:39 AM by Woody

# re: What About Workflow and ASPX Forms?

Hello -

I found this post really useful and was able to create an ASPX form to collect association data for my workflow.  I am missing one piece though - if the user is editing the workflow, how can I determine which workflow?  

I noticed that the AddWrkfl.aspx page 2 querystring values - ListID and TemplateID.  When the user clicks the Next button to get to my ASPX form, the TemplateID is dropped from the querystring.

Any help is appreciated!

Tuesday, February 06, 2007 4:51 PM by Cindy

# re: What About Workflow and ASPX Forms?

Hi Eilene, Just found the form values that are posted with workflow information.  Thanks anyway!

Tuesday, February 06, 2007 5:56 PM by Cindy

# re: DelayActivity Hotfix

Hello -

I just received the hotfix for KB#929816 for the DelayActivity issue.  Unfortunately, the KB article is not public and the hotfix didn't include any instructions.  Can anyone tell me if:

1)  Does this hotfix need to be applied to JUST Front End web servers OR ALL web and Application servers in our Sharepoint farm?

2)  Is a REBOOT or IISreset required after the hotfix install?

Thank you!

Wednesday, February 07, 2007 7:26 PM by Carl

# re: What About Workflow and ASPX Forms?

Eilene,

I am really struggling to put together an ASPX workflow form based upon the ASPXCollectFeedback example - I think it's quite hard to understand.

Could you or someone else please post the *simplest* possible ASPX workflow form possible - e.g. an initiation form that is just a single ASPX and class file and only has one data field - like just a string?

If possible, could you also annotate both files with comments about what is boilerplate code and what should be modified?

Many thanks.

Thursday, February 15, 2007 6:44 AM by Kris

# re: What About Workflow and ASPX Forms?

Looking at the collectfeedback sample, the amount of "plumbing" code seems excessive.  A lot of mundane data persisting and sharepoint manipulation work is required by the developer every time.  Are there any plans to make this development easier and let the developer focus on their domain problem instead of spending the bulk of development doing lower level plumbing to make sharepoint/workflow operate together?

So far I've spent maybe 10% of my time working on the actual workflow and 90% trying to get the forms and their underlying responsibilities to play nice in the sharepoint workflow environment.  Granted I'm new to sharepoint development, but not asp.net.

Thursday, February 15, 2007 1:20 PM by Eric

# re: DelayActivity Hotfix

I just tried calling PSS twice to get the hotfix for the delay activity issue and got nowhere.  One person told me that it didn't exist and the other kept saying that it was "greyed out" but didn't explain exactly what that meant.  Any advice on how to get this hotfix?  Is it still available?

Thanks.

Friday, February 16, 2007 3:39 PM by Mark

# re: What About Workflow and ASPX Forms?

I also got the same response from PSS.  Does anyone have any information about it or can someone who did receive the hotfix please share it with the community?

Saturday, February 17, 2007 3:55 PM by Robert

# Workflow and ASPX Forms

when i am starting the workflow i am getting following error message.

please suggest me

-----------------------------------------

Error

----------------------------------------

{"The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."}

-2130575251

  at Microsoft.SharePoint.Library.SPRequest.ValidateFormDigest(String bstrUrl, String bstrListName)

  at Microsoft.SharePoint.SPWeb.ValidateFormDigest()

  at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflow(SPListItem item, SPWorkflowAssociation association, SPWorkflowEvent startEvent, Boolean bAutoStart, Boolean bCreateOnly)

  at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflow(SPListItem item, SPWorkflowAssociation association, String eventData, Boolean isAutoStart)

  at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflow(SPListItem item, SPWorkflowAssociation association, String eventData)

  at InitForm.InitiateWorkflow(String InitData) in c:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\WorkflowForms\InitForm.aspx.cs:line 137

-----------------------------------------

Sunday, February 18, 2007 3:54 AM by krissh

# re: What About Workflow and ASPX Forms?

I was able to get the hot fix from the PSS group. I just opened a trouble ticket with PSS and they sent me the hot fix KB 929816 and reimbursed my money as it was a bug in the product.

Tuesday, February 27, 2007 11:47 AM by Amar

# re: What About Workflow and ASPX Forms?

I’ve got a custom aspx form that shows up when my workflow is associated with the document library.  There’s a bunch of code that associates the workflow with the task and history lists for the association when you click the Ok button on the custom form.  That all works.  The error occurs at the very end of the click event when I try to do a Response.Redirect to the ‘all done’ page.  I get a ‘Thread was being aborted’ message and SharePoint gives me the standard ‘Oh No, Mr. Bill!’ screen that it always shows when it gets cross about something.  Now, the association succeeds, I can go back to the document library, trigger the workflow, and have it work.  The only thing that seems to be broken is the redirect itself.  I’ve tried using both Response.Redirect, which the SDK code uses, and SPUtility.Redirect, which seems more appropriate to use.  Both give me the same error.

Tuesday, March 06, 2007 6:21 PM by Jim

# re: What About Workflow and ASPX Forms?

I am trying to retrieve data from an aspx task form. I am using the SPWorkflowTask.AlterTask method.

This method has 3 arguments. The first argument is of SPListItem type that maps to the task. Please I need help to know how to set this argument properly.

Thursday, March 08, 2007 1:59 AM by Bernadette

# re: What About Workflow and ASPX Forms?

The collect feedback example doesn't contain an aspx form for a task, the task uses a default aspx page.

I created an aspx page with its associated C# class for a task in my workflow but i have a problem in interacting with the variables of the workflow.

The AlterTask method throws a null pointer exception when it is executed.

this is the code that I am using:

SPWeb web = SPControl.GetContextWeb(this.Context);

SPList tasks = web.Lists["Tasks"];

SPListItem m_listItem = tasks.GetItemById(Convert.ToInt32(Request.Params["ID"]));

SPWorkflowTask.AlterTask(m_listItem, taskHash, true);

I initialised the taskHask argument from aspx fields.

I didn't found any documents or something that may help me in solving this exception.

does anyone have an idea how to solve it??

Monday, March 12, 2007 4:47 AM by Bernadette

# re: What About Workflow and ASPX Forms?

Hi everyone,

I know that there's an example of the use of aspx forms in the SDK (WSS & ECM StartersKit), but this example is really complicated. Does someone has a simple example?

thanks in advance.

Tuesday, March 13, 2007 4:47 AM by sven

# re: What About Workflow and ASPX Forms?

This post is excellent as it nearly matches my requirement.

i want to associate multiple task edit forms with a workflow for different stages of workflow e.g when workflow is in initiation stage edit for is different(no need to have approve button etc), approver stage(approver button is required, also some of other fields would become read only and similarly for other stagesof workflow).

can somebody please help me in understanding how it can be done.

Cheers

Tuesday, April 24, 2007 1:20 AM by leo

# re: What About Workflow and ASPX Forms?

Hi,

Does anyone know how to fill an aspx Task Form from teh workflow??

Usually from InfoPath we use the createTaskProperties.ExtendedProperties and pass in the name of the field in teh ItemMetadata? How does this work with aspx pages.

Waiting your soonest reply,

Thank You,

Zeina

Wednesday, April 25, 2007 3:04 AM by Zeina

# re: What About Workflow and ASPX Forms?

Response to Wooody - did you find a resolution?  I also have the problem where I am creating/editing the .aspx form in the ASPXCollectFeedback example and just can't get it validated or displayed in the designer as it is missing the referenced masterpage, and many of the other assembly references in the asp-code report.  

Any help appreciated.

Thanks.

Camie

Friday, June 01, 2007 6:41 PM by Camie

# re: What About Workflow and ASPX Forms?

Camie and Wooody, I've experienced the same problem trying to open the sample in the designer and there are tons of errors because it can't find the referenced materpage. Has anybody succesfully gotten the sample to work?

And are there any plans to recreate the ASPCCollectFeedback example in VB?

Thanks,

CLM

Wednesday, June 06, 2007 3:58 PM by CLM

# re: What About Workflow and ASPX Forms?

Hi Is it possible to configure workflow on multiple docuemts instead of one. And during the approval process of a task, is it possible to attach more documents along with task approval?

Thanks

Kevin

Thursday, July 19, 2007 4:37 AM by Kevin

# re: What About Workflow and ASPX Forms?

Hey guys - I'm currently knocking something like this up for my TechEd session (aussie teched a little after US).

One of the positions I'm starting from is:

Using SPD to create and associate the WF to a list.

I've made sure the WF has an initialisation + task edit form.

You can then use the SPD to go and examine the automagically created forms. Essentially there is a SPWorkflowDataSource with some pretty cool params (i.e. ItemID=QueryString(ID)) - with functions to automatically pull values from the QueryString.

The next part of the page is runs the results of the SPWorkflowDataSource through an XSLT and viola - that's the page you see.

I've found that this is a pretty simple way to start - rather than looking at seriously busy forms.

There are a couple of mouse overs and other bindings that are pretty hardcore, but essentially 2% is tough, 98% is all good.

HTH,

Mic.

Tuesday, July 31, 2007 8:54 AM by Mick Badran

# re: What About Workflow and ASPX Forms?

I found a good book that comes with some sample aspx page files.

Try this one:

apress publishes it (as of May 2007)

Workflow in Office 2007 by David Mann

Wednesday, September 05, 2007 8:38 PM by nw

# re: What About Workflow and ASPX Forms?

Hi Eilene,

        which are the best forms to use with workflows infopath or aspx forms?

Wednesday, September 19, 2007 1:16 AM by chandrika

# re: What About Workflow and ASPX Forms?

can u send one example on aspx forms in workflows.

how to read the aspx form date in workflows and how to sart the workflow in aspx page.

can u send one sample work flow on this.

Regards

sapthagiri

Friday, September 21, 2007 11:14 AM by sapthagiri

# What should i type for this to run?

Hi, i am trying to use an infopath template under a workflow, but when i try to use it in MOSS 2007 this error appears "The form has been close" and i don't knwo what is wrong.

here it is my workflow.xml

 <?xml version="1.0" encoding="utf-8" ?>

- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

- <Workflow Name="Workflow del Libro" Description="Workflow del libro que usa Infopath" Id="930C46DC-0C6B-4b2e-A094-7B2A6F665E48" CodeBesideClass="MarketingCampaign.Workflow1" CodeBesideAssembly="MarketingCampaign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=193953a0d8d07aa2" TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160" AssociationUrl="_layouts/CstWrkflIP.aspx" InstantiationUrl="_layouts/IniWrkflIP.aspx" ModificationUrl="_layouts/ModWrkflIP.aspx" StatusUrl="_layouts/WrkStat.aspx">

 <Categories />

- <MetaData>

 <Instantiation_FormURN>InitForm</Instantiation_FormURN>

 <Task0_FormURN>TaskForm</Task0_FormURN>

 <AssociateOnActivation>false</AssociateOnActivation>

 </MetaData>

 </Workflow>

 </Elements>

the initform.xsn and the task.xsn are in the same directory as the feature and the workflow.xml are

can someone help me?

thx in advance

Wednesday, October 17, 2007 5:30 AM by Veelicus

# re: What About Workflow and ASPX Forms?

For those of you who are still struggling with workflow forms, I've written a series of workshops on Custom ASP.NET Workflow Forms (How to).  You can download them from my blog here: http://rshelton.com/archive/2007/10/05/sharepoint-document-workflow-with-visual-studio-workshop-documents-download.aspx.  I am not on the SharePoint team, but I am a Technology Evangelist for Microsoft Public Sector.  

Wednesday, October 24, 2007 1:48 PM by Robert Shelton

# Porque hacerlo fácil si se puede hacer difícil... SharePoint Tipos de Contenido, Flujos de Trabajo y cosas de esas

Flujos de Trabajo basados en el WorkFlow Foundation creados para SharePoint son algo entre maravilloso

Saturday, November 17, 2007 5:17 AM by SkunkWorks

# Porque hacerlo fácil si se puede hacer difícil... SharePoint Tipos de Contenido, Flujos de Trabajo y cosas de esas

Flujos de Trabajo basados en el WorkFlow Foundation creados para SharePoint son algo entre maravilloso

Saturday, November 17, 2007 5:18 AM by SkunkWorks

# re: What About Workflow and ASPX Forms?

I have problems getting the aspx to use my GAC assembly. "cannot load type <assembly>".....

No help in the net so far...

Sunday, November 25, 2007 8:00 AM by thor

# re: What About Workflow and ASPX Forms?

Hi,

  In IniWrkflIP.aspx page, I need to disable the approvers text box, search users button and the message box. Could you help on this to get the control name of those...

Monday, December 10, 2007 7:04 AM by Vimal

# re: What About Workflow and ASPX Forms?

I have create a workflow and deploy it correctly but when i want to started it, this error appears: field to start.

my workflow.xml has no StatusUrl i dont no why.

<?xml version="1.0" encoding="utf-8" ?>

<!-- _lcid="1033" _version="12.0.3015" _dal="1"   -->

<!-- _LocalBinding   -->

<!-- Insert Workflow.xml Code Snippet here.  To do this:

1) Right click on this page and select "Insert Snippet" (or press Ctrl+K, then X)

2) Select Snippets->Windows SharePoint Services Workflow->Workflow.xml Code -->

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

 <Workflow

      Name="Fred"

      Description="This workflow ..."

      Id="{54DACFA6-DB5B-456f-8BBF-A7CDD88D0774}"

      CodeBesideClass="WFAssociation.Workflow1"

      CodeBesideAssembly="WFAssociation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=e4ce737f80348db7"

      TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"

   <Categories/>

   <MetaData>

     <Modification_GUID_Name>Name of Modification</Modification_GUID_Name>

   </MetaData>

 </Workflow>

</Elements>

Tuesday, May 13, 2008 8:54 AM by Tony

# re: What About Workflow and ASPX Forms?

To get the extendedProperties from the custom aspx form, use the method SPWorkflowTask.GetExtendedProperiesAsHashTable(<your taskListItem>)

Friday, May 16, 2008 4:54 AM by Ilyes

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker