Skip to main content

I have a workflow process in which I need to change the InfoPath view before uploading the document at several different stages. I tried installing the Change InfoPath View Wizard from the black market but it did not add any wizards to my toolbox (I did reset the toolbox several times)


Then I tried to use a server code event as show below but it did not work either. (The name of the InfoPath form is "Simple Approvals")




using



using



using



using 



using



using 



using 



using 



using 



using 



namespace 



{



 



{



 



{



 



xmlDoc.LoadXml(K2.ProcessInstance.XmlFields.



 



 


K2.ProcessInstance.XmlFieldsc0].Value = xmlDoc.OuterXml;}


}


Any ideas?


thanks,



Luis


ExtenderProject_8d54de7eea4440bf8e25630e017124ea public partial class EventItem_bacf4fb1d49548788f22f64a80796f5a :ICodeExtender<hostContext> public void Main(Project_8d54de7eea4440bf8e25630e017124ea.EventItemContext_bacf4fb1d49548788f22f64a80796f5a K2) XmlDocument xmlDoc = new XmlDocument(); "SimpleApprovals"].Value.ToString()); XmlNode k2Node = InfoPathHelper.GetK2Node(xmlDoc); InfoPathHelper.SetK2FieldValue(k2Node, "DocumentView", "ReadOnlyView"); hostContext = Project_8d54de7eea4440bf8e25630e017124ea.EventItemContext_bacf4fb1d49548788f22f64a80796f5a;SourceCode.Workflow.Common.Extenders;SourceCode.Workflow.Common;SourceCode.KO;System.Xml;System.Drawing;System.Collections;System.ComponentModel.Design;System.ComponentModel;System;


Maybe this will help.


The technique I typically use when saving out an archive version of the InfoPath form is to use the Data event.  Inside the data event I navigate to the _K2 node of the InfoPath form and populate the DocumentView with the name of the view (i.e. Archive View) and then right after the Date event I use the SharePoint document event to upload the form to the SharePoint library.


K2 automatically adds rules to the InfoPath form so that it will automatically switch the view of the InfoPath form to whatever is in the DocumentView field which in this case is the Archive View.


Regards,


Tim


I have not used a data event before. If the name of the view is "ReadOnlyView" what are the steps to use a data event to change it?


thanks,


Luis


 


 


The data event is one of the most useful events that you can use in your process configuration.  I'd recommend running through the wizard a few times to become familar with it but its relatively easy to use.


Here is a screenshot from one of my processes populating the DocumentView with "Print View".  Of course you'd just subsitute "ReadOnlyView" in your case.  The last step is to upload the InfoPath form to some location. 




The last step is to upload the InfoPath form to some location using the SharePoint document event:



 



 



 



 



 



I followed your example but I still cannot get the view to change. How did you set your source field?


thanks,


Luis


 


 


If you're referring to the 2nd screenshot for the Data event that is just free text that I typed in.


If you're referring to the SharePoint document event and the Document Upload Source.  That should be pointed to the process XML field that K2 automatically creates after you integrate your InfoPath form with the process.


Thanks for your help. I got it working. Know I just need to figure out how to get the url of the saved document so I can add it to an email.


That's relatively easy.  One way would be to save the document save results results out to the content field and in my example access the URL node of the UploadedForm content field in the email.


To do that in your SharePoint Document event in the Upload Document Destination screen add a checkbox to the "Add a Document to this Content Field.  Then click on Create and give your content field a name like UploadedForm.  That will create a new XML field and you can then access the URL nodeof that XML field  in the K2 Object Browser in an email event after the documents been uploaded.


 



Reply