Worklist Item status


Badge +7
Hi,

I am now in my first serious test phase with my project so there is more then one user (only me) included in the process. I am working with fully trusted Infopath forms signed with certificates and erverything works just great. The problem I have is: I have an activity with two destionation rules (one goes to is my self the other a team member).
After I submit the start page we can both see the worklist item in our worklist with the status "Available" but if one of us accepts or enters (or call it however) the item it still shows the status "Available" for the other user. In both the Service manager and the workspace. Shouldn't it be signed as "Allocated" ? What is wrong ? If that doesn't work with infopath I guess I'll run into serious trouble.
Help would be a lot appreciated.
Thx in advance.

17 replies

Badge +7
How many destination slots have you specified for the activity?

If you set this value to 2, it works in a normal way to let the status as available.
Badge +7
Hi Tanguy,

thanks. I haven't thought about that at the moment it is still set to 1 slot. I am gonna try it out directly an let you know if it worked.
No stop just read your post again. I don't want it to be set as available it should be set up to allocated if one takes the item. So will it help if I set the slot to two ? Hmm just gonna try it.
Badge +7
I'm not sure I was explicit enough...

If you set 1 destination slot, the task list item will disappear from the second user task list.
If you set 2 destination slots, the task list item will still be available in the second user task list
Badge +7
But that is exactly what i did.
I have 1 slot for two users but the item still appears as available for the one who didn't take the item.
Do you have any further ideas.
Badge +7
Which task list are you using ? the sharepoint one or the workspace one?

What is the status of the task for the user who opened the form? look at it without closing the form, is the status set to "Open" ?
Badge +7
That is the strange thing.
First I am talking about the Workspace Worklist Items cos unfortunatly I am not using sharepoint so my Infopath forms are published to a webserver.
Lets assume I am the one who enters or opens the Worklist Item in the Workspace then it shows still the status available for me and the status for the second user (in his workspace) is also still set to available and even more, he can also open the form even if I have done that already.

By the way, thx for you effort
Badge +7
Ok so the problem is that opening the form doesn't make K2 to set the activity as opened...

Unfortunately, I'm not good enough with Infopath to help you further
Badge +7
Ok thx anyway.
Hope that may be Renier, Ockert or Neil or someone else will have some advice for me tomorrow.
Badge +11
To better understand InfoPath Activities in general, please have a look at Neil's post here:
http://forum.k2workflow.com/viewtopic.php?t=997

And to answer this question specifically, please have a look at:
http://forum.k2workflow.com/viewtopic.php?t=770

Regards,
Ockert
Badge +8
the behaviour you are seeing is expected in an InfoPath client event. When the InfoPath form is opened, the CanISubmit method of the InfoPathService.asmx is called. Part of this call is to open the worklist item, but it is not allocated to the user opening the form.
As I understand, the reason for this behaviour is because the user may not know whether they want to accept the worklist item until they see the form data.

Off the top of my head I can suggest some workarounds for this behaviour:
If you always want the task assigned to the user and you are using a cutom worklist, you can use the K2Connection.OpenWorkListItem(serialnumber) method or
WorkListItem.Open() to change the status of the worklist item before directing the user to the URL of the worklist item.

Alternatively, you can add code to the load event of the infopath form to call the K2Connection.OpenWorkListItem(serialnumber) method to force the item's status to change. (Note that you can only use managed code in InfoPath forms with Office SP1 or higher. Otherwise you will have to use scripting and probably create a web service that can call this code for you.)
If you want the user to decide whether they want to accept the task item or not before submitting the form, then you could add a button on the form which calls K2Connection.OpenWorkListItem(serialnumber) method.
Badge +7
Hi Neil,

first thx for all the information, already helps to see the things more clear. But what do you mean by "custom worklist" and where exactly do i have to put the code "K2Connection.OpenWorkListItem(serialnumber) or WorkListItem.Open()" ? Till now I haven't used any code in within K2at all. All code I am using is in my Infopath forms. I guess that if I want to use the K2Connection.OpenWorkListItem(serialnumber) method there I have to reference some K2.dll, but may be it would be better to put the code to K2. Could you please help.
Badge +7
I have a new problem,

as NeilM decided (good idea) I added a button to my view and the Users can decide wether they want to set the status of the task list item to open or if they want to leave it to someone else. I use this code:
SourceCode.K2ROM.Connection myK2Conn   = new SourceCode.K2ROM.Connection();
SourceCode.K2ROM.WorklistCriteria myCriteria = new SourceCode.K2ROM.WorklistCriteria();
myK2Conn.Open("luxdevas02");
SourceCode.K2ROM.Worklist myWorkList = myK2Conn.OpenWorklist(myCriteria.Platform);

foreach(SourceCode.K2ROM.WorklistItem myWorkListItem in myWorkList)
{
string strSerial = myWorkListItem.SerialNumber.ToString();
myK2Conn.OpenWorklistItem(strSerial, myCriteria.Platform, true);
}
myK2Conn.Close();

The status change works and the worklist item gets allocated for the other users but the problem is that lets say I have 10 WorklistItems in my Worklist and I open one Item (Infopath form) and press the Accept button that the status of all 10 Items is set to open and so they are all allocated for all other users. Of course that is not what I want. Can someone tell me what is wrong with my code. I think that I have to be more specific about which Item I want to change the status for but how ?

Thx in advance.
Badge +11
Yes, you're right - you would have to be more specific. Currently, you're looping through all the user's worklist items and change the status of each of them.

One way to fix this I suppose (although I haven't tested it), would be to store the Serial Number in a process datafield as soon as the worklist item is created. Then in InfoPath, bind an invisible text box to the Serial Number datafield and only open the worklist item with that specific serial number.

Hope this helps,
Ockert
Badge +7
Thx I am gonna try that.
Badge +7
One additional question. You said store the number as soon as the worklistitem is created. Am I right that I then can put my code into the Infopath Initialize Server Event. That is the event where the WorklistItem is created isn't it ?

Somehow I don't get it. I can not get the SerialNumber (in the Code I posted before) before I am in the FOREACH loop. In K2.net Server or Client events I cannot use the K2Rom cos of the protection Level of SourceCode.KROM so how can I actually do what you posted in your idea.
Am I missing something essential here ??????

Anyway thanks for the help!
Badge +8
If I remember correctly, there is a my:SN element in the K2InfoPathSchema XML Activity Datafield which contains the serial number for the activity already. You can then use that value to open the worklist item.

Note that if you have the serial number, you can also open a worklist item directly without needing to loop through the collection of worklist items - have a look at the OpenWorkListItem method of the K2ROM's Connection object.

If my:SN does not work, have a look at the code of the InfoPath client event - this is the code that adds the worklist item to the user's worklist.
You can reference K2.SerialNumber in this code and you can then assign the serialnumber to an activity datafield or even store it as part of the temporary InfoPath file's name.

Note at the end of the code is the code is a line "K2.AddWorklist("ASP",FileURL);" - this is the method that adds the worklist item to the user's worklist.

Hope this helps,
Neil
Badge +7
Hi NeilM,

thank you more than a LOT. I think that did it now and your response came just right on time cos I have prensentation of the Project today and the status thing was the only big problem which was left at the moment.
Anyway I want to thank all for the fast and good support in this forum and hope that I also can help some others in future. But I am sure I'll also come back with some questions :oops:

By the way here the code for those who may be face the same problem:
IXMLDOMNode nodeSN   = thisXDocument.DOM.selectSingleNode("my:myFields/my:_K2/my:SN");
// Write your code here.
// Sets the Worklist Item Status to Open after Accept butten was clicked
SourceCode.K2ROM.Connection myK2Conn = new SourceCode.K2ROM.Connection();
SourceCode.K2ROM.WorklistCriteria myCriteria = new SourceCode.K2ROM.WorklistCriteria();
myK2Conn.Open("luxdevas02");
myK2Conn.OpenWorklistItem(nodeSN.text, myCriteria.Platform, true);
myK2Conn.Close();

Reply