Skip to main content
We are in the process of creating a worflow process for maintaining performance reviews for employees for the projects they have worked on. We want to use infopath for this. For the first time, HR creates an infopath form for an employee and adds the project he worked on. Then it goes through a process where the related people add their reviews and finally the form is saved in the document library(K2 process completed). It works fine till here. Now we want then when there is a second project, the HR open the searches and opens the same form and adds a project and submits it again. This should again start the same workflow process. It seems from all that I have read that infopath integration is only when a new form is created in the forms library that has been extended by K2. I tried usign the sharepoint event for monitoring updates to library but that got into more problems. I would really appreciate if you could guide me how to start a new infopath process when a previosly completed infopath form is opened and submitted with changes.

Regards,
Anshu
Try creating an event at the very end of your process that makes a copy of the XML form then emptying the "my:_K2/my:SN" element make K2 think it is a new submission? You will probably have to modify others nodes, too, so InfoPath and your process don't get their knickers in a twist 😉 You could then save the form somewhere, probably the document library, for later retrieval.

I haven't tried it, but it's worth a try...In fact I can think of a use for this in the process I am currently working on 🙂
Hi,

I think it will work. I stared once something similar but put it to the bin again. In my opinion it is better to save the information entered into the InfoPath document in a seperate database which you can then qurey when filling out a new one.

For the thing you want to do sirwally is right and you shoudl empty some of the k2 specific nodes. I had a button on my form with the following:

Try something like this:

   string strTmp = thisXDocument.DOM.xml.ToString();
string strXml = strTmp.Replace(strTmp.Substring(strTmp.IndexOf("<my:_K2>")),"");
strXml += @"<my:_K2><my:SN></my:SN><my:ConnectionString>k2server="Your server";k2process="Your process"</my:ConnectionString><my:DocumentView>View 1</my:DocumentView><my:DocumentViews>View 1;View 2;View 3 View...</my:DocumentViews><my:ExtraInfo></my:ExtraInfo><my:Folio></my:Folio><my:FolioField>"Your Folio Field Definitions" </my:FolioField><my:ViewFlowData></my:ViewFlowData><my:ViewFlowURL>"Your Vewi Flow URL Path"</my:ViewFlowURL><my:DestinationUser></my:DestinationUser><my:CreateViewFlowLink>False</my:CreateViewFlowLink><my:UseChachedViewFlowData>False</my:UseChachedViewFlowData><my:DisableSubmitButtonDestination>False</my:DisableSubmitButtonDestination></my:_K2></my:myFields>";
doc.LoadXml(strXml);

doc.Save("Your Path" + "Your File Name" + ".xml");


Hope it is a little help
I am a newbie to K2 but this makes perfect sense to me. I still don't understand how do I kick off a new process from that infopath document.
Hi abansal,

first one question to you. What makes perfect sence now using the database behing or the code I posted to you ?

Anyway it is a kind of hard to guess what exactly you want but...

You have this performance review InfoPath document which is routed through different steps till the review is completed. After the completion of the request it gets saved somewhere including all the information entered during the instance. Then when a new review is needed you want to open the old file (including the information) and start a new instacne where users add additional information.
So my first suggestion is that you put all controls of the InfoPath document into a repeating table.
Then in the button event of the last submit button / view use code similar to the one I posted already. Then the next time when HR wants to use the form they open the saved form, click the insert item button underneath the repeating table. A complete new empty section will appear. Then they can enter their data, submit the form and so on...
Like this you should be able to achieve what you want. I am not 100% sure but it's worth a try.
Hello Nukkumatti,

Thanks a lot for helping me try to figure this out. If I am understanding it correctly what you are saying is that that one of the columns in the repeating table would be a submit button added by default whenever you add a new row. When HR clicks this submit button, it will kickoff a NEW process instance. So this submit button basically has all the code to start a new infopath process. I have to probably use the infopath tool kit as this code would be in VB.net, rite?. Can you guide me how could I get the sample code for starting an infopath process. I am sure it gets written somewhere when we run the infopath wizard, so maybe I can copy paste it.

Thanks again,
Anshu
Nukkumatti,

I am sorry I forgot to answer the question. I would use the code mentioned by you and not external database.

Thanks,
No you got me a bit wrong.

Lets assume you have a repeating table or repeating section in you infopath document.

in this tabel you have three textboxes. outside the table you have a submit button.
Lets say textbox1 is filled out from HR. -> they click submit and the document comes to the first activity in your process.

In the event of this activity the user opens the form and fills in textbox2.
He also submits the form after that and it gets routed to a second activity. Lets say this is your last activity in your workflow.
This user fills textbox3.

So what you should have for this scenario is a infopath template which consits out of 3 views and each view is bound to an activity in your workflow. In each view you have a custom submit button.

To make these buttons work you can call
OnSubmitRequest(null) to submit the form and start a process instance in the first place.

Now in the event where the user fills out textbox3 you use additional code behind the submit button. The code i posted before.

Like this the complete document with the three filled textboxes is stored somewhere.

Now if HR want to start a new instance they open this saved form. The insert item button i mentioned is a default setting if you use repeating sections and appears directly under this section. HR would click this button/link, now a new section with three empty textboxes would appear directly under the three filled textboxes. HR can fill textbox1 of the three new empty textboxes and submits the form and you run through the whole process again. The next time there would be six textboxes filled out already and you can add three new.

Does this make more sence ?
Where are you from by the way do you have ICQ may be i can support you then a bit better.
Ok, I tried something else but am stuck again. I added a button on the form and added the following code on it. thisXDocument.Submit();

I then removed the option for submit button task pane. Now a user come to the forms library open a new form and clicks this submit button and the process starts. As the last part of the process, i have added a sharepoint document event which saves this infopath form as a form in the SAME document library. Now when a user comes and opens this form. If the user belongs to HR role, then only he sees the form. When I log in as the HR and click this button again, I get the following error:

The SOAP response indicates that an error occurred on the server:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: *An exception has occurred. Unable to open the K2.net Worklist Item.
Worklist item not found*
at InfoPathService.K2InfoPathWS.SubmitInfoPathData(Object pArrayData)
--- End of inner exception stack trace ---

Could someone help me understand what is the code that runs when you open a new infopath form from a document library on which infopath wizard has been run. When I open the infopath form, nothing shows up in the K2 server console but it seems from the above code that K2 server is creating a worklist item. When we click the submit button on the NEW form, this worklist item kicks off a new instance of the proces. Isn't there any way this could be done through and old form opened in the same library.

Any help would be greatly appreciated.

Thanks,
Anshu
Hello Nukkumatti,

It seems we were typing replies at the same time. My ICQ number is 221-955-557.

Thanks,
Anshu

Reply