How to set DataField value in K2 Workflow?

  • 20 July 2009
  • 1 reply
  • 4 views

Badge +4

Hello,


I have integrated web page in K2 workflow in which depends upon datafield value i will be making visible some controls.


In more details:


1) Whenever workflow will start two K2 worklist task will be generated at a time, for both the task i have used same web page.


2) So, depends upon datafield value I need to visible different controls for both the tasks.


I have tried it assigning datafield value in server code event but its not working.


Is anybody aware how to achieve it?


Thanks,


Sush.. 


 


 


1 reply

Userlevel 1
Badge +8

Hi Sush,

I am not 100% clear on what you are doing. When you say, Integrated Web Page, are you talking about SharePoint Workflow Integration Web Pages?

If you are wanting to dynamically render controls on the page based on a K2 process data field, you will need to choose to "Generate Forms" when you run your SharePoint workflow integration process wizard (if you are going this route). This will give you access to customizable .NET pages. (Or if you are just using a regular ASP.NET pages for a standard K2 workflow you can edit the code there as well.)

 I have used the same approach you have to control the behavior of a form based on a process data field. You are going the right direction by setting the process data field in a code event. My question is, is your server event that contains your code BEFORE the client event in your process? Events in an activity are executed in a linear order from top to bottom. So, if you have your server event that sets your process field value AFTER the client event, then I can see how it would not be working as the field is never set as the process is waiting on the client event to complete before the server event code is executed.

Once you have the order of your events worked out, all you have to do is use SourceCode.Workflow.Client API to access the process data field and evaluate to make something happen. The API call that you will use will be something like WorklistItem.ProcessInstance.DateFields["datafieldname"].Value. This will give you access to the process datafield value that you could then put in an if statement or other control syntax to make changes to your .NET page on the fly.

Hope this helps.  

Reply