Populating a Viewflow URL for use in InfoPath forms services

  • 21 July 2008
  • 0 replies
  • 0 views

Badge +6

Within a rich client infopath document view, you are able to display the K2 Submit bar which includes a viewflow url.  However, if you are using forms services, this submit bar will not be available and pulling together a proper url from the supplied K2 data group is not intuitive.  Here are a few quick steps you can follow to include viewflow urls in your form views that occur after the process has already started.  (note that you cannot display the viewflow until a process instance has been created)


1)  Add a text field to your InfoPath XML primary datasource and call it:   ViewFlowFullURL


2) Add a hyperlink to the view and set it's value to the ViewFlowFullURL field you just created


3) In the workflow, create an initial activity (just after START) and place a Default Server Code Event there.


4) Add the following code, customizing "SchemaName" with the name of your own infopath schema.  (you can confirm this SchemaName by drilling into your K2 Object Browser > XMLFields > the one below "Activities" is your SchemaName)


            string XMLString;
            
            //customize SchemaName in the following line
            XMLString = SourceCode.Workflow.Common.Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields["SchemaName"].Value, "/my:MyFields/my:ViewFlowFullURL", K2.StringTable["Web Service URL"] + "/Workspace/TaskListControl/ViewFlowMain.aspx?ProcessID=" + K2.ProcessInstance.ID); 


            //customize SchemaName in this line also
            K2.ProcessInstance.XmlFields["SchemaName"].Value = XMLString;


5) Once the initial activity has run the code you put in place, the value will persist in the XML schema and you will be able to add "ViewFlow" urls to all subsequent views.


0 replies

Be the first to reply!

Reply