JunHOV

Hello,

Is there any example/tutorial for building SharePoint state machine workflow using VS 2005 and InfoPath I need an example with a few states and one InfoPath form for each state. The state is role based, it would be more helpful.

Thanks




Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Sudhe

Hi Jun,

Were you able to find an answer to your post

If yes, please let me know if there is an example on how to work with the Sharepoint State machine workflow .

Thank You,

Sudhe.





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Aaron A

Do you have any specific questions regarding state machines

The ECM kit contains a sample state machine....i have done one also, so i'm very familiar with them if you have any questions.





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

JunHOV

I would need a step by step tutorial on how to develop a SharePoint state machine workflow library using Visual Studio 2005 and InfoPath similar to the SharePoint sequencial workflow library example which is available in many sources (a form with instructions field, comments field and approved checkbox).

If a complete example/tutorial is not yet available, I would like to ask the following questions regarding the Task Form or Task Edit Form (NOT the association and initiation form):

1) On the InfoPath form, instead of one SUBMIT button for sequential workflow, I would need multiple buttons (APPROVE, REJECT, REVIEW, etc.) for state machine workflow to move the work item to different state (for example, APPROVE button click moves the item to APPROVED state, REVIEW button click moves the item back to UPDATE state, etc.). How do I configure the InfoPath form buttons to trigger the different event handlers

2) With SharePoint sequential workflow, we always use the onTaskChanged activity to handle the SUBMIT button click. With state machine workflow, which SharePopint workflow activity we can use to sever as OnTaskApproved, OnTaskRejected, OnTaskReviewed, etc. which will response to corresponding button click and move the item to corresponding state. If all we use is onTaskChanged only, how do we configure it to response to different button click

I would need some basic clarification on both the workflow side and the InfoPath form side, that's why I think a complete example would be the best.

Thanks,

Jun






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Aaron A

That's similar to what I did....

There is a book you can pick up by David Mann, the only book out there so far for workflows and it covers that stuff heavily. He posts on this forum a lot that i've noticed as well.

The only thing you will do in the forms is set values, the forms will do nothing more than provide interaction for workflow tasks. The workflow will read these values in through a hashtable in the aftertaskproperties.extendedproperties["field name"]

There is a lot of stuff online....I'm not at my office right now or I could provide some links (I'm actually sitting in a SharePoint training class).

Like your approve/reject/review buttons would only set a value such as

approved = true

then the workflow has an if/else activity that has a condition based on those 3 values then targets the specific state you are wanting to go to based on which value is true. rinse and repeat...

the book is worth its weight in gold





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Sudhe

Hi Aaron,

I am completely new to Sharepoint and Workflows.

Here is my requirement :

I have an already existing Sharepoint site .This site consists of a Defect Log List (that would track the various defects posted as a result of Software Testing).

The requirement needs me to customize this List by binding a new state machine Workflow to it.

Now , from what I have understood from the stuff online :

I am supposed to use the Sharepoint State Machine Workflow Library in the VS 2005 using Infopath.

Here are my questions:

1.)I have an already developed Sharepoint site.So where can I access the Infopath forms(.xsn and .xsf files) of this Site. inorder to use them from VS.

2.) Most of the articles online for Sequential workflows state that each workflow would contain an onWorkflowActivated activity , a while loop and so on.

How would this be implemented for a State Machine workflow

3.) My software defect would transition from one State to other when the User Edits an item in the Sharepoint List and clicks the "OK" button.

Should I capture the OK_click event of the List item and call the handleExternalEvent handler in it

or

Shoould I just call the event handler whenever an Item is edited

Can you please provide me some links which would be helpful,also can you mention thename of the Book b'coz I have come across many books online and not sure which one to get !

Thankyou,

Sudhe





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Sudhe

I have installed th ECM starter kit.

When I try to view the SPSMWorkflow.cs file I receive the error message :

ERROR LOADING WORKFLOW

An error occurred while loading the wrokflow.

The variable 'FaultProperty' is either undeclared or is never used.

Can someone tell em how this can be fixed

I've tried declaring a new dependency property named FaultProperty but this doesn't make any difference.

Thank You,

Sudhe





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Aaron A

Workflow in the 2007 Microsoft Office System by David Mann

http://blogs.msdn.com/sharepoint/archive/tags/Workflow/default.aspx

Here's David's website, he's agregating a lot of workflow websites here, look under "resources"

http://www.kcdholdings.com/




Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

JunHOV

Aaron,

Thanks for your suggestions. I actually have the gone through the book Workflow in the 2007 Microsoft Office System by David Mann and I agree that this is a good book. I can implement the SharePoint sequential workflow successfully. However, the state machine workflow example provided there (project name: ResetTaskOnChange) is too simple and does not apply to my case for the following reason:

1) It doesn't have any task form involved

2) The two key activities used in the state are onTaskChanged and onWorkflowItemChanged, which response to the change to the document itself (like re-upload the document), not the task form updates.

3) I want to know at one state, how I can configure multiple onTaskChanged activities with each of them handling different event (approve, reject, review, etc.)

4) I want to know how to tie the different event to different buttons at the InfoPath form side.

If you have done something similar to this, could you probide more detail on the both workflow design side and InfoPath form side A quick work through of some sample application would be very helpful.

Thanks,

Jun






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Ahmad Atwi

Jun,

For each state created add the following controls (StateInitalization,StateFinitalization, and an EventDriven)

in the StateInitalization you add the OnTaskCreated Activity, in the EventDriven you add the OnTaskChanged Activity and for the StateFinitalization you add CompleteTask Activity.

You can handle the task current task property under the function of the OnTaskCreated, so there you can associate the task to its respective infopath form by using the following line of code:

Code Snippet
ontaskcreated1_properties.TaskType = num;

"ontaskcreated1_properties" represents the properties of the OnTaskCreated for the current State.

"num" represents an integer which is defined in the workflow.xml and that holds the id of the Infopath.

for example if your for your first task the num variable will be 0, and for the second task it will be 1.

so in your workflow.xml you should add code similar to this

Code Snippet

<Task0_FormURN>InfoPathID</< FONT>Task0_FormURN>

<Task1_FormURN>InfoPathID</< FONT>Task1_FormURN>

In this way you will be assigning every task to one InfoPath that you have created earlier, and when you want to handle the changes done to the form then you should do that under the OnTaskChanged function of each task.

For the case of the Approve Reject issue, you can create a variable in the InfoPath form that is set to a value based on the button clicked. and then from the OnTaskChaned function you can retrieve the value of that variable and based on it you can complete in processing the workflow.

For the case of the Approve Rejecect issue, you can do the following:

InfoPath Side: Create 2 Buttons Approve, Reject and and a new variable to infopath whose value is set based on the button clicked.

Design Mode: after the OnTaskChanged Activity and and IFELSE Branch Activity, and let it have 2 branches (it can handle as many branches as you want) one branch will be for Approval and the other for Rejection. Set the Condition Property of the Branch to CodeCondition and associate it to a function (you dont have the above step for the last right branch it does have to be set to Code Condition by default if the workflow does not enter any of the branches then it will enter the last right branch if it has no condition set to it).

under the OnTaskChanged function get the variable's value

the code condition for the apprval branch should be like this

Code Snippet

private void handleCondition(object sender, ConditionalEventArgs e)

{

if (value = "Approval")

e.result = true;

else

e.result = false;

}

when e.result is true the workflow will enter the branch else it will move to the next branch.

Hopefully this gave you an idea of what you want. If anything is not clear i can explain it more.

Best Regards

Ahmad Atwi






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

JunHOV

Thank you very much for your input. I will try it out and let you know how it goes.

If you have any sample implementation of this type, could you post it here It would make things easier for me to learn from a working example.

Thanks






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

JunHOV

Ahmad,

I implemented the state machine workflow following your instructions above and it worked! Many Thanks.

Now I need to add the role based task assignment to the workflow. The user/role is from Active Directory. I want to map each of the STATE in the state machine workflow to a user group/role in AD (like manager, sales, etc) and only users in the targeted group can process the work item. To extend this requirement more, how to allow the task to be re-assigned to another user by admin user.

Please share with me if you have any experience in this area.

Thank you






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Fred Morrison

When assigning the TaskType, I find it useful to first create an enum with meaningful symbolic names that match the Task0, Task1, etc. InfoPath forms (Approve=0, Review=1, etc.). Yes, you have to cast them as (int), but it sure helps when handing off the code to somebody else, especially it that person is new to writing custom SharePoint workflows. I'll be demonstrating this technique when I make my presentation on custom SharePoint workflow development in VS (2005 and 2008 beta 3) to the Northern Virginia SharePoint User's Group meeting on Thursday, September 13 at the Microsoft office in Reston, VA.






Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Leo Yulianto

Dear Friends,

I'm also new in this Workflow things. I need alot of help that can guide me how to build a system. Currently i need to build a workflow for my testing. This are my requirement:

1. I Upload a file (let see XLS file)

2. After upload, i need to inform Supervisor of the staff who submit the file that their staff submit a file. The information through email

3. After supervisor received email, supervisor can check the file, after check supervisor can do Approve or reject

4. when approve, email notification will inform finance site and staff site that supervisor approve. When approve the finance also do like supervisor did.

5. When reject, email notification sent to staff that their file rejected.

6. When finance receive notification from supervisor then finance will check and also give result approve or Reject.

7. when approve, the email notification to Managing Director will be sent. After that MD will check and also so approval or rejection.

8. If finance reject, then sent email to supervisor and staff that finance reject

9. If MD reject then sent email to Finance, Supervisor and Staff regarding of rejection from MD.

May i know how to make workflow like that Is it using Sequantial or State machine workflow I really need your help.

Please help me. Thank you





Re: SharePoint - Workflow need example for building SharePoint state machine workflow using VS 2005 and InfoPath

Nguyen Van Nam

Hi Ahmad, Did you add the role base task assignment to the workflow as your needed If so, pls share your solution to me

Thanks very much,

NamNV