Skip to main content
Is there a way to put an activity to sleep automatically when it starts?

I want to hang an activity off of the first activity that can be used to edit the InfoPath form at any point along the process. The person receiving this activity can access it using the Workspace with a filter showing the sleeping activities.

Most of the time it won't be used, but it might need to be used is certain circumstances. For xample, some process instances may be active over a year, and the originator may have changed jobs during that time. This would be a way for an admin to assign a new originator. In any case this activity would be cancelled when I get to the end of the process by using a GoToActivity to move to the final activity, which completes the process.

I'm trying to use K2ROM to access the worklist, find the item, and put it to sleep in the client event code, but when I try to add a reference to K2ROM I get the following error message: The file : C:Program filesK2.net 2003inKWROM.dll is an assembly that contains unmanaged code, please add this assembly into the GAC and load again.

I'm not sure what to do at this point.
Any ideas on how to accomplish this?
The short answer for this is No, the sleep method is only exposed by K2ROM and not available from within a process. A good example of why I should use sleep is best explained in the following Scenario:

To complete a Task I need to contact a specific client (let say Bob) and get some more information from him before Approving the request, Bob s assistant said that he is currently on a conference and will only be back tomorrow at 8 AM. Based on that fixed time I would like to get the item from my worklist simply because I cannot do anything with it until tomorrow at 8 AM. I will calculate the time based on 8 AM and sleep the item for that duration, effectively all you have done is change the items status so that it no longer shows in your worklist based on the default filters (Show items that is Item.Status = Available or Open ). The cool thing about it is that K2.net Server will handle the timer that is needed to change the status back to Open as soon as the duration expired, you can see this as a task that K2.net Server logged based on the sleep duration you have specified. Tomorrow at 8AM the item will be back and I can continue with whatever is needed to complete the task.

About K2ROM, we don t allow you to reference K2ROM from within a Process, this is by design.

Maybe if you elaborate a little more about your scenario we could provide some ideas around the best implementation of it.
Maybe if you elaborate a little more about your scenario we could provide some ideas around the best implementation of it.

Our workflow is a Management of Change application and has about 70 steps in it. A large InfoPath form is filled out to initiate the workflow, and it goes to several approvers before moving on to a series of review steps - design, safety, environmental, etc. Then it continues on thru a series of startup and completion steps.

An external database defines several 'roles', and these roles are populated with user IDs by cost center. When the originator fills in the IP form, as he selects the cost center these various roles are populated from the db. These roles are then used as the destination users for most of the workflow activities.

One such role is MOC Coordinator. He needs the capability of editing anything on the form at any given point during the lifetime of the workflow, which may be up to a couple of years. My idea was to hang an activity (Edit MOC) off the beginning that goes nowhere (except a line to itself to restart if it is used) and doesn't hold up the workflow. This activity would use a view that allows this coordinator to modify certain xml fields - for example, the originator field (for example, in the case of a long-lived MOC and the originator has retired). The next to last activity in the workflow would use a GoToActivity event to proceed to the final activity, which would have the effect of cancelling the Edit MOC activity.

The desire for putting it to sleep is to keep it out of the MOC Coordinator's worklist, as he may have many such process instances going on at any given time. He could access them either by using the provided email with link, or using the workspace with a filter showing the sleeping items. I know that the coordinator can go to his workspace and put it to sleep, but if we could do it programmatically at the time of instantiation it would be a big help.
I think there are a couple of options without using Sleep.

Are you using the K2.net Workspace application for your task list? If so, you can create a couple of worklist views, one that shows all activities where Name is Not Equal To "Edit MOC" and the other where Activity Name Is Equal To "Edit MOC". The MOC Coordinator could then work all "real" K2 on the first view but still locate his/her Edit MOC tasks on the second view if/when the MOC Coordinator needs to.

If you are using a custom worklist (i.e. you wrote your own .NET app utilizing the K2ROM .NET assembly) you can do something very similar to above utilizing the WorklistCriteria object on the Connection.OpenWorklist() method.

Another option may be to utilize a different "Platform" for the "Edit MOC" Client Event. By default, K2 generates client events with a platform of "ASP". However, you can override this by generating & editing the code for the client event, which in your case is probably an InfoPath Activity Event (which is actually a client event under the covers), and using any string value you want (perhaps "EditMOC"). Please note, that K2.net Workspace will only display worklist items/client events with a platform of "ASP", so if you need to display a list of these, you'll need to create a custom worklist and pass in the appropriate Platform string on the OpenWorklist() method.
Bob,

We are using the K2 Sharepoint WebPart for the tasklist, but advanced users (such as the MOC Coordinator) will probably use the K2 Workspace for other tasks.

I've tried setting up a filter on the tasklist to not show activities where the name is 'Edit MOC', but I can't get that to work either.
I'd make sure that the you are referencing the correct name. You can set a view to filter by Activity Name and/or Event Name. I've been known to enter the Event Name in the Activity Name field.

Would it be possible to attach a screen shot of the filter dialog? I've attached one as an example.
Hi Steve,

to come back to your original question:
Put the K2Rom.dll (you can find it in under C:Program FilesK2.netin) into your C:WindowsAssembly folder. Thats it. Now you can use the K2Rom within your infopath doc.

Hope this helps.

Reply