Skip to main content
Hi All,

OK, I'm fairly sure I'm missing something really stupid here!

A user opens a form (/taskmanagement/default.aspx) to create a new workspace. They input details like workspace name, etc. The form gets submitted and the workflow kicks off - it creates the workspace and adds an entry for it in a list.

In the list, I have a column called "complete task". A hyperlink goes into this column. When clicked, the link should take you to another form (/taskmanagement/CompleteTask.aspx).

This second form holds all the information that the first one did (workspace name, description etc) in inactive fields. There is an active field for adding a comment. When the form is submitted, the list should get updated.

However, when the second form loads, it is a blank page - ie, the form loads correctly but none of the existing data is there.

Can somone explain to me how this should work?

Form1 (/taskmanagement/default.aspx) is a PlanPage. The submit button is a PlanButton. This form is associated with the solution, process, etc, but not with a specific activity.

After creating the workspace, I write to a list. I write the "complete task" URL as [servername]/taskmanagement/CompleteTask.aspx

Form2 (/taskmanagement/CompleteTask.aspx is a PlanPage. The submit button is a FinishButton. This form is associated with the solution, process and with a specific activity (Complete Task).

In K2, the Complete Task activity contains an Client Event. This is specified as a webpage URL [servername]/taskmanagement/CompleteTask.aspx.

Can anyone advise me how to associate the second form with the process instance?

Sorry for the complicated and long post, and many, many thanks for any help.

Rich
Hi Richard,

Form2 should be a Client page AND...

Since it's associated with a Client Event, the URL should also contain a Serial number in order to open the correct client event - something like:
http://[server]/[site]/[Page].aspx?sn=[K2.net_generated_serial_number]

Hope this helps,
Ockert
Hi Ockert, thanks for the swift response.

I have set Form2 to be a ClientPage.

The URL for the ClientEvent is:

http://[servername]/[site]/CompleteTask.aspx?sn={SERIALNO}

The page loads fine but again, none of the existing data is there.

The URL that I am actually CLICKING on (the one written to the list) is http://[servername]/[site]/CompleteTask.aspx

Do the two need to match?

Can you explain the serial number to me? Is a Serial Number that gets generated by K2? Or do I need to generate it myself at the beginning of the process.

Many, many thanks for your help. I know this is probably an obvious question but I don't remember this problem occuring in any of the training modules.

Rich
the link you need to click will have to include the sn so smartforms knows which process instance to get the data from. you'll have to manyally append the sn=xxxx,xx string to the link.
Ok, thanks Ashley that makes perfect sense.

So this leads me to (hopefully) my final question for today!

How can I get the serial number for the current process instance, into, say, a process data field? Therefore letting me generate that link automatically each time I start a new process?

Cheers!

Rich
You can get the serial number with K2.SerialNumber - the serial numer is uniqe to each *activity* instance, not process. so you'll have to create the link accordingly.
I'm very sorry about all the hand-holding required here but I still don't exactly follow.

Do I need to create a new server event in my first activity to obtain the serial number from K2, allowing me to write that to a process data field and hence incorporating it into the link?

Also, if a serial number is unique to an activity instance, I don't understand how this will work.

eg

Activity One - Create Task - workspace is created, I obtain a serial number, write to list (including serial number in URL)

Activity Two - Complete Task - click the link which passes the serial number through to the smartform. However - I'm now in a new activity - so therefore the serial number from Activity One is no longer vaild?

Please excuse my limited grasp of what I'm trying to do here.

Many thanks,

Rich
At some point, the process will move into an activity with the client event which require the user interaction. You need to add the code and generate (or update) the link using the serial number from the process at this point.
Ok fantastic, I understand now.

So I will write to the list in each activity rather than just the first one.

Then I can click my link at either stage of the process and get the correct page.

Does it seem logical to pass the serial number into a process data field? This seems like the obvious way to dynamically generate the link.

I think that's it for now..... A massive thank you to Ashley and Ockert and everyone else that has helped me out today.

Rich
Right, I knew it couldn't be quite that simple!

To facilitate trouble shooting I have deleted everything apart from the first activity.

The activity looks like this:

Start Immediately
1 - Obtain Serial No. (server event)
2 - Create New List Item (sharepoint list event)

This writes a link to the list:

http://[servername]/[site]/CompleteTask.aspx?sn=[k2 data field w/serial number)

3 - Create task site

This works fine - the site gets created and listed. The link to completetask.aspx kind of works - ie, when I mouse over it I see the correct link and it includes a serial number in the form:

http://[servername]/site/CompleteTask.aspx?sn=[servername],69,38

However clicking the link leaves me in the same situation. The page loads but none of the existing data is there?

Answers on a postcard? Seriously, I appreciate all the help given today and hope I am nearly there with this now!

Cheers,

Rich
the serial number changes on each activity so, you'll have to update the link for each activity.
Yeah, I understand that... However for testing, I deleted everything apart from the first activity.

So the serial no. getting written to the link is definately accurate as it was obtained within that activity.

Seems like I am missing something in my smartform?

Many thanks,

Rich
Hey Rich,

I can see you're going to struggle with this one a bit more...

A couple of things to keep in mind:
1. Serial Numbers are generated for EVENTS i.e. a 'Default Server Event' will have its own unique serial number AND a 'Default Client Event' will have it's own unique serial number.
2. Event instances are duplicated for each Destination user i.e. ClientEventA meant for UserA will have SerialNumberA = [Server],[ProcInstID],[User A's Event Instance's ID] while ClientEventA meant for UserB will have SerialNumberB = [Server],[ProcInstID],[User B's Event Instance's ID].
3. Smartforms (Client Page) uses the OpenWorklistItem method to access the appropriate process instance id (obtained from serial number) i.e. you need a valid/existing worklist item to access the process instance.
4. The only way to create a valid worklist item is by using a 'Default Client Event'.

In other words, what you basically need to do is the following:
1. Create a Plan Page which will Start your process.
2. From the Start, go to an Activity containing a 'Default Client Event'
3. Add a Destination User for this Activity.
4. Go through the Client Event Template wizard to point the client event to your Client Page.
5. Generate the code behind the client event.
6. In this code, you'll see the worklist item being created with the appropriate serial number.

One of two options here...

6a. Save this serial number to a process level variable to be used in a parallel process path creating the site and list entries.
6b. In the same code, check whether the site already exists. If not create the site and add the list stuff here using the above serial number.

You will definitely run into a couple of problems like timing of worklist item creation and site creation. Also, when more than one user is involved, authentication may become a problem.

Try to keep it as simple as possible and grow it from there.

Note: Use Console.Writeline() statements for troubleshooting and run K2.net Server in Console mode to monitor the outputs.

Hope this helps,
Ockert
Thanks Ockert.

Richard, I didn't read your last post properly. It was early morning.
Thanks Ockert that was a detailed and thorough reply.

I would like to ask some follow up questions.

Please see the attached screenshot.

My process splits into two after it starts.

The default activity contains a client event with this code:

.Value - K2.SerialNumber;
K2.Syncronous = true;
}


So it points to the correct URL, the code is there to create the worklist item and retrieve the serial number, and then pass the serial number into the "TaskSN" process data field.

The second activity, Create Task Site, waits 1 minute after planning before starting. It then writes the list item, creates the site, and performs a couple of server events.

The second activity IS working, but the link created to "complete task" omits the serial number. So clearly it is either:

a) not getting written to my process data field
b) not getting written there before the link is created

Can anyone spot an obvious flaw in my logic here?

Also, why the need to run this client event in a parallel activity? Surely it would make more sense to have it as the first event within the Create Task Site activity.

Many, many thanks again.

Rich
Change:
.Value - K2.SerialNumber; 
K2.Syncronous = true;
}

To:
/default.aspxsn={SERIALNO}"; 
strURL = strURL.Replace("{SERIALNO}",K2.SerialNumber);
K2.Addworklist("ASP",System.Web.HttpUtility.UrlPathEncode(strURL));
}


The wait 1 minute after planning is a good idea.

True, logically it would have made more sense to just have the Client Event as the first event in the Create Task Site Activity BUT...

The problem is that the process flow would not continue to the next event in line (i.e. creating the site) UNTIL the Client Event has been finished - obviously, you can not do that because then the serial number would once again not mean anything and you would not be able to 'connect' to the worklist item.

The rest of your process flow, should obviously follow the Activity containing the client event and NOT the site creation Activity.

Hope this makes sense,
Ockert
Thanks Ockert the code worked perfectly.

So my process starts, runs the default client activity which creates the worklist item and writes the serial number to [taskSN].

The Create Task Site activity waits one minute after planning then starts. The workspace gets created and the details are written to the list, including the "complete task" link. The link gets written as expected, with the serial number obtained in the client activity.

Clicking the link launches the appropriate form, but the data entered into the first form is still not present.

Any further thoughts?

Many, many thanks for your continued support.

Rich
OK, maybe something wrong with your Plan Page. Make sure that after you've planned a process instance, that the appropriate datafields are set. You can add a new (temporary) activity with a default server event after 'Start' which writes out the datafield values to the console.

Regards,
Ockert
Hi Ockert

My PlanPage appears to be fine- I'm writing all the datafield values I need to the console immediately after "start" and they are all valid.

Just to confirm, within visual studio:

Form 1 - Create Task -

Page Type: PlanPage, Submit Button: PlanButton

7 K2SmartControls on the page - text boxes, dropdownlists and radio buttons - that need to be displayed on the finish page are ALL passing their values through to K2 (as evidenced by writing to the console).

Form 2 - Complete Task -

Page Type: ClientPage, Submit Button: FinishButton

The form loads correctly. It is obtaining the serial number previously obtained in a parallel activity (it is visible in the URL). It just does not pick up any of the values from the first form?

Can you spot an obvious problem here? Note that I have tried this with Form 2 set as both a clientpage and a planpage, with no difference.

Many thanks,

Rich
And your K2Controls contained within your Client page are 'bound' to the correct DataField values?

Difficult one...
Ockert

PS!! Forget for a moment about the Sharepoint List Link and open the user's K2.net Workspace Worklist. Open the Smartform from there and see if the controls/values are populated.
Yes, all the controls on the Client Page are bound to the appropriate data fields.

Opening through the worklist produces the same results.

This is a bit of a nightmare!

Rich
True, a nightmare indeed...

Have you got access to the training material?
I would suggest you go through module 3 (I think) building the simple travel request process using smartforms. From this you would hopefully be able to pin-point the location of your current problem.

Otherwise, please open a formal support ticket through the Partner and Customer portal ( http://portal.k2workflow.com ) and attach your K2.net solution files as well as your VS.NET solution files for the support engineer to have a look at.

Sorry I couldn't be of more assistence,
Ockert
Ockert,

I do have access to the training material and will dust off Module 3 as suggested!

Hopefully this will help narrow the problem down.

If not, I will open a support ticket.

Your assistance has been great and very helpful, I now at least possess a much greater understanding of some of the concepts involved here.

Many thanks for your time and patience,

Rich

Reply