Friday, September 26, 2008

Debug MOSS Workflow in Visual Studio

This blog is very late to be publishing at this point (given I ran into this a long time ago) as many know how to debug a MOSS workflow. All you need to do is:

  • Make sure that you get a debug build in the gac.
  • Restart IIS or recycle the SharePoint app pool, which ever you prefer.
  • In Visual Studio >> Debug >> Attach to Processes… >> select the w3wp.exe.

Now, do not forget to Attach to only the Workflow Code Type.



Apparently you cannot debug workflow and managed code at the same time. Otherwise, you will find yourself closing Visual Studio, bouncing IIS and re-opening Visual Studio just to debug your workflow… Doh!

Thursday, September 25, 2008

Denver K2 User Group SmartObjects

Update 4/16/2009 - here is a link to the recorded presentation.

I have been asked to speak about SmartObjects at the Denver K2 User Group. I will be doing it virtually. If you like to attend, please tune in. It will be a nice intro into all of the aspects of SmartObjects and if you have any questions, please come with them.

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

Hello everyone,

The next K2 User Group meeting in Denver is fast approaching and will be held on October 7th from 6pm to 8pm.

The meeting will again be hosted at Baxa located at 14445 Grasslands Dr, Englewood, CO 80112. Here is a map to the Baxa office. There is plenty of parking available around the building and it's fairly close to E470, so please join us in person, if possible. For those of you who cannot attend in person, we will have a Live Meeting session available. This information is located at the bottom of this e-mail.

Please RSVP to me by Friday, October 3rd whether you will be attending in person (so we can plan for food) or via the Live Meeting. If you are interested in receiving these notifications in the future, please register for the Denver User Group on the K2 Underground. If you would prefer to not be contacted again, please let me know so I can remove your name from the list.

Agenda:

6:00 - 6:15 Networking/Refreshments

6:15 - 6:30 Announcements

6:30 - 7:15 Presentation by Jason Apergis from RDA Corporation

7:30 - 7:45 Round Table Discussion

7:45 - 8:00 Meeting Wrap-up


Presentation Summary:
Jason will be talking about the beauty and power of K2 SmartObjects. During this session Jason will be going into the SmartObject basics but will also show you how to create them and their associated ServiceObjects.

Jason Apergis is a software consultant who has lived in the Washington, DC area his entire life. Jason currently works for a Microsoft Gold Partner named RDA Corporation as a technical project manager and has worked for various other consulting firms like BearingPoint and AMS. One of Jason's solutions was nominated as a finalist for a Microsoft solution of the year award in 2006 which integrated K2, BizTalk, SharePoint and InfoPath. Jason completed both his undergraduate and graduate degrees in Information Technology from Virginia Tech. Jason plays ice hockey weekly basis and is both an avid Washington Capitals and Virginia Tech Football fan.

Bring your questions or challenges for a round table discussion after the presentation to discuss with the others in the User Group. Have you used SmartObjects yet? How are you using them? What challenges have you faced?


Live Meeting Information:

Start Time:

Tuesday, Oct 7, 2008 6:00 PM MDT

End Time:

Tuesday, Oct 7, 2008 8:00 PM MDT

Occurrence:

Recurring meeting

Meeting Lobby:

Not enabled

Attendee URL:

https://www.livemeeting.com/cc/scna/join?id=CK6G4W&role=attend&pw=F59%3EKcr

Meeting ID:

CK6G4W

Attendee Entry Code:

F59>Kcr

Location:

Audio:

Two way computer audio conferencing: Off

One way computer audio broadcasting: Off

Telephone conferencing: On

Audio conferencing provider: Other

Toll free: +1 (913) 227-1219Toll: +1 (888) 269-6500

Participant code: 994729

Note: please keep your phone on mute until you are ready to speak.

Wednesday, September 24, 2008

K2 blackpearl 0807 Released

Important news 0807 build of K2 blackpearl, that I previewed here, has been released. There are major changes and bug fixes that have been addressed. Below is the announcement.

K2 blackpearl™ 0807 (4.8210.1.0) is now available!

Greetings K2 Customers!

K2 blackpearl™, the centerpiece of the new K2 platform, has the K2 blackpearl 0807 (4.8210.1.0) release now available.

The 0807 release focused on greater stability and better performance than ever before. It includes various enhancements and performance increases for the K2 Workspace, the K2 Designer for Microsoft Visual Studio 2005, and the K2 blackpearl Workflow Server to name but a few. It also includes post-0803 patches and bug fixes. New exciting features included in this release are Out of Office functionality and K2 Interop!

OUT OF OFFICE

The K2 Out of Office feature enables a user to share specific worklist items or their entire worklist with other users. The user, the out of office participant, will be able to share current and future work items with designated colleagues, and redirect all remaining items to others by creating exception rules. The additional column on the K2 Worklist allows users to differentiate between their own and the absent colleague's worklist items. This functionality ensures that important and urgent work items receive prompt attention, regardless of someone being away from their desk.

K2 INTEROP (Moving Process Definitions from K2.net 2003 to K2 blackpearl – CLIENT SIDE)
K2 Interop (short for interoperability) is the ability for K2.net 2003 process (.kpr) files to be opened in the K2 Designer for Visual Studio that ships with K2 blackpearl. It is a client-side, design-time functionality that allows converted K2.net 2003 and hybrid (K2.net 2003 and blackpearl) processes to be deployed to K2 blackpearl. With the release of K2 blackpearl, organizations with an investment in K2.net 2003 may want to leverage the advantages of the new platform and migrate their existing business processes from the old platform to the new. From a technology perspective, K2.net 2003 is distinctively different to K2 blackpearl, and K2 blackpearl offers a whole new feature set however still supporting the same K2.net 2003 features moving forward. As a result the divide between K2 blackpearl and K2.net 2003 is bridged by supporting K2.net 2003 features within the K2 blackpearl environment using K2 Interop

MIGRATION (Moving existing K2.net 2003 Process Instances to K2 blackpearl – SERVER SIDE)
K2 blackpearl 0807 is now migration-ready. The migration utility will be released in the next few weeks and is NOT available immediately. It is important to note that you will require K2 blackpearl 0807 to use the Migration Utility. The Migration capability should not be confused with K2 Interop. Migration is the physical migration of data from K2.net 2003 to K2 blackpearl. This is a server-side, runtime functionality enabled by a separate utility that migrates database records from K2.net 2003 to K2 blackpearl.

NEW ACTIVE DIRECTORY SERVICE
The New Active Directory Service provides new objects and methods to access information from Active Directory for easy access and use of information to help create business processes and workflows in K2 blackpearl. This service surfaces information from AD and has a great number of performance enhancements and added functionality along with the functionality contained in the original Service, however it does not replace the original one.

PERFORMANCE ENHANCEMENTS
Numerous performance enhancements have been implemented. Some of the highlights are as follows. Workflow Server Performance

> Improved processes execution
> Worklist & Worklist Item performance
> Worklist enhanced paging and filtering capabilities
> More granular selection on Workflow Reporting SmartObjects
> Improved memory usage on K2 Designer for Visual Studio
> Improved memory usage when starting processes and finishing work list items
> Improved batch execution of K2 processes
> SmartObject Performance (runtime execution)
> SmartObject Server data handling enhancements


ENHANCEMENTS ON K2 WIZARDS
Some changes have been made to the functionality which resides behind the scenes of the K2 Wizards – specifically the items used for Microsoft SharePoint Server integration. These wizards now leave a smaller footprint on the process definition (.kprx) files, resulting in smaller file sizes and better memory management in the different designers available for K2 blackpearl.

DOCUMENTATION
Several additions and enhancements have been made to the K2 blackpearl Documentation. The key areas of improvement are as follows.

OVERALL DOCUMENTATION
Certain topics of the K2 blackpearl documentation has been updated and new topics added. New or updated topics are marked with an asterisk image in the Table of Contents

The following sections contain new or updated information:

> K2 Concepts - Content Fields
> K2 Wizards - Chaining wizards
> Mail Event
> IPC Event
> SharePoint Records Management Wizard
> Deploy Project Wizard
> K2 SmartObject Integration - SmartObject Association
> K2 for Visual Studio - K2 Design Canvas
> K2 Interop
> K2 Workspace - Management Console
> Out of Office
> Standard Reports
> User Preference
> K2 Developer Reference - Architecture of K2 Platform
> Users
> Extending the K2 Platform

Please take the time to review the latest K2 blackpearl 0807 (4.8210.1.0) Release Notes and product documentation before installing 0807 to ensure you understand the enhancements, fixed issues, and outstanding known issues.

For installation, we urge you to look at the Release Notes prior to Installation! There are two issues that you should be aware of before installing 0807 that may, depending on your current blackpearl installation, overwrite custom configurations.

DOWNLOAD K2 BLACKPEARL 0807 (4.8210.1.0)
K2 blackpearl 0807 (4.8210.1.0) is available at
https://portal.k2workflow.com/downloads/bp/Default.aspx.
License keys can be obtained at
https://portal.k2workflow.com/licensekey/Default.aspx.

The page can also be found via the Support > License Key Request > License Key menu on portal. The 0807 installer is slipstreamed, so if K2 blackpearl is not already present, the installer will install K2 blackpearl with the 0807 updates.

Saturday, September 20, 2008

MOSS Workflow History Best Practice

If you are designing a workflow solution in MOSS on of the first things you may think about incorporating into your solution is the Workflow History. The value proposition of using the Workflow History was:

  • When building workflows there is an activity you can drag right onto the process which will set values into the Workflow History table. It is really simple to use.
  • Users will be able to see all of the information immediately right there on the screen in the Workflow State page.

However after doing some more thinking and contacting a few of my colleagues I quickly decided not to use it to any great degree. Here are a couple of the issues that are with it.

  • First, the workflow history table will be cleaned up by SharePoint after a period of time. This time can be configured using the AutoCleanupDays however it will be run at some time. It will not actually delete the logs, but it will delete the log associations to the workflow instance and it will delete any tasks that are associated to the workflow instance.
  • Second, I got concerned with sizing of the workflow history list in general given the 2,000 item rule for a list. If you use it a lot you will quickly eclipse this and there can be performance issues. So the workflow history will have to have data deleted from it on a regular basis.
  • Third, in my opinion there is no real good way to search, query or do business reports of this data.
  • Fourth, since workflows can be removed from a list. Once the workflow is deleted, if you go back to the item the workflow instances will be deleted. This basically means to me that this data is not well managed.

The best practice in my opinion is to use the workflow history if you want to print out some quick information to the user on the workflow page or if you want to use it as a way to do some logging. It should not be used as a solution to satisfy auditing requirements. If you have that as a requirement, I would highly recommend dumping some data out to a custom database which can scale and is easier to query.

References:

Workflow Task Form Data Connections

Error

While I was working with a state workflow in SharePoint I ran into a problem with make secondary data connections my Task forms. I was getting the infamous "5566 An error occurred accessing a data source".

Background

Well Google was giving my tons of hits on the error but nothing helpful at all. I basically had a custom web service that I needed my Task form to use. Here was the situation:

  • I had a data connection a web service which I had converted and placed into a Connection Library in SharePoint.
  • Had changed the form properties to be Full Trust.
  • When I ran the preview of the InfoPath, the data connections were successful.
  • Here is where it gets interesting. I was able to deploy the form through central administration (because the form had full trust) and then associated the content type to a form library. When I opened the form as a web enabled form, it worked!

That last bullet completely confused me. Why would it work if I deployed the form manually but when the same InfoPath form was being used in a workflow it would not work?

Solution

After digging at it for a while this is what I found. Data connections that were executed through a rule would work however and data connections that were executed when the form was opened would not. For instance, I had a dropdown that I wanted to be loaded when the form was opened. So when I created the data connection on the last step of the wizard I set it to "Automatically retrieve data when the form is opened". My solution was to clear that checkbox and then go to Tools >> Form Options >> Open and Save >> and press the Rules button in the Open behavior section. I then added a Rule to query the data connection and then everything worked. Really strange…

Thursday, September 11, 2008

DelayActivity Not Working and Creating Simple Escalation

Scenario
Basically I want to start adding some escalations into my SharePoint state workflows. I want to send emails to people who have been assigned a task.

Error
When I put a Delay Activity into my state workflow, the delay activity would not work. No errors; no nothing. I put in some break points and the event definitely fires however it never wakes up to send the email.



Resolution
I did some searching and found out rather quickly this seems to be a well known error. Specifically this SharePoint team blog lead me to KB 953630 which discusses the issue. To resolve the issue I had to resolution 1 and 4. First I had to install KB 932394 which just required me to bounce both IIS and the SharePoint Timer service. Next I had to modify the Job-workflow timer using the Stsadm. Let's say you have a reminder that must be sent within two hours, if the Job-workflow time job is configured to go off once a day, your reminder will not be sent.

The reason why I had to install this KB is because my client has not installed the Infrastructure Update for Microsoft Office Servers (KB951297). If you have not installed it yet, please do so! There are a ton of good fixes.

Setting up the Escalation
So to implement an escalation into my state workflow, I simply added two Event Driven activities by right clicking the state. The first uses an OnTaskChanged activity which waits for a user action. The second is the escalation.

Now in the EscalationActivity, I simply put in a delay, an email and a log. Done.
Escalations in Thoughts
In K2, I do not even have to think about how to set up escalations but I had to figure out how to do in WF. First of all from what I read the DelayForActivity and DelayUntilActivities activities that you may see in the tool box have some challenges and work well in SharePoint Designer; not in Visual Studio fromw what I read. I knew I really did not need to use them, so I stuck just to DelayActivity.

I found these two blogs sending a reminder in a sequential workflow and using nested StateActivity to send regular reminders in Visual Studio SharePoint State Machine Workflow. Really they were overkill from what I found and the second article basically was hacking at the workflow to achieve a result where a user will continue to receive reminders until the person takes action. LET ME IMPLORE YOU; I would challenge any business user who claims this is a requirement for an everyday business process. I have seen way to many scenarios using workflow engines (at different client) where set up complex business rules and had expectations that users would be doing stuff in rapid fashion. Trust me, you are building a spam machine and the business users will hate you for it, especially if escalations are going up to the CEO. I HIGHLY recommend that you put in simple escalation rules or none at all until you can do some analysis of the workflow once it has been automated. Once you start collecting rich data about the process, you will identify bottlenecks and that is when you want to start introducing escalations.

Wednesday, September 10, 2008

WF Error Correlation Token Already Initialized

Error


This is another error I ran into which I found really interesting.


System.InvalidOperationException: Correlation value on declaration "managerTaskToken" is already initialized. at System.Workflow.Runtime.CorrelationToken.Initialize(Activity activity, ICollection`1 propertyValues) at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken(Activity activity, Type interfaceType, String methodName, Object[] messageArgs) at System.Workflow.Activities.CallExternalMethodActivity.Execute(ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext) at System.Workflow.ComponentModel.ActivityExecutorOperation Run(IWorkflowCoreRuntime workflowCoreRuntime) at System.Workflow.Runtime.Scheduler.Run()


I did some and I found this rather quickly - http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/347537b5-7710-4576-98e9-fcd7b023ff0e/


Resolution


This error was really interesting to me and had to do with my lack of knowledge of the inner workings of WF. Here is a screenshot of an early iteration of sequential workflow I am creating.




In the workflow, the manager could reject back to the requestor and then the requestor will submit back to the manager for approval. Simple enough right? This error would occur after all of the resubmission events had completed and the state had gone back to the ManagerApproval state. What is happening is that I have different tasks created for each state which have their own tokens. To resolve the error make sure that on the CreateTask properties window that you select the name of the "state" for the OwnerActivityName and not the name of the "workflow" (in this case I select ManagerApproval). When the correlation token is set to the "state" it will be re-initialized when the state is created again (i.e. when the requestor resubmits back to the manager). The one thing to take note of is that once you do this the task cannot be reused in other states.