Skip to main content
Nintex Community Menu Bar

Reading from DataFields

  • February 11, 2008
  • 5 replies
  • 18 views

Forum|alt.badge.img+2

Hello,


I'm writing some code in a K2 custom server event through K2 for Visual Studio. In the code below, I've found that I can easily write to K2.ProcessInstance.DataFields, but that I can't seem to read from the DataFields.


//Set date submitted
K2.ProcessInstance.DataFields["Date Submitted"].Value = DateTime.Now.ToShortDateString();


//Get Document Attributes
LogMessageToFile("Doc ID from DataFields = " + K2.ProcessInstance.DataFields["Doc ID"].Value.ToString());


The Date Submitted is correctly set and I can read from it later through the K2 interface. The message logged to my text log file shows a blank in the place of the Doc ID value. I know the Doc ID has a value b/c I also am writing the Doc ID to a column at another step and can see the correct value in the column on my SharePoint site.


 Has anyone else seen this behavior, or am I missing a step?


Thanks,


Kim

5 replies

Forum|alt.badge.img+11
  • February 12, 2008

There should be no problem reading DataFields.  Has the "Doc ID" field been set before this step? 


Forum|alt.badge.img+2
  • Author
  • February 14, 2008

Yes, the Doc ID has been set as noted above:


" I know the Doc ID has a value b/c I also am writing the Doc ID to a column at another step and can see the correct value in the column on my SharePoint site."


Forum|alt.badge.img+6
  • February 15, 2008

This might look like a long way to do the same thing but I've seen this sometimes help (not neccessarily with K2 DataFields but in general)


string DocID = K2.ProcessInstance.DataFields["Doc ID"].Value.ToString();
LogMessageToFile("Doc ID from DataFields = " + DocID);


Does that make any difference?


Alternatively, could you attach to the server process with (remote) debugging and step through the code to check what's happening with the data fields?


 


Forum|alt.badge.img+8

There should be no problem readin data fields, i am able to set/get that in my code


if

(item.ProcessInstance.DataFields["whatever"].Value.ToString() == "yes").


do have a look in code and make sure that your are setting it , also if you could post all code.


If problem is solved , do post a solution so that all of us can see the solution.


 


Cheers!


 


Forum|alt.badge.img+2
  • Author
  • February 25, 2008

Looks like GLouw's solution worked.


Thanks!