Skip to main content
Nintex Community Menu Bar

How to update ActivityInstanceDestination.DataFields programatically?

  • September 26, 2007
  • 8 replies
  • 31 views

Forum|alt.badge.img+4

Hi,



I need to update some ActivityInstanceDestination.DataFields programatically. My code looks like this:




Connection.Open(connectionString);
WorklistItem worklistItem = Connection.OpenWorklistItem(serialNumber, "ASP", true, true);
UpdateProcessDataFields(worklistItem.ProcessInstance); // Get data from UI and puts into process' datafields
UpdateActivityDataFields(worklistItem.ActivityInstanceDestination); // Get data from UI and puts into activity's datafields
worklistItem.ProcessInstance.Update();
worklistItem.Release();
Connection.Close();

My problem is that the Activity's datafields doesn't seem to update, only the Process' datafields...

Any tips?

Sincerely,

Cato Antonsen

 

8 replies

Forum|alt.badge.img+4
  • Author
  • September 27, 2007

Sure - very simplified:

private void UpdateProcessDataFields(ProcessInstance process)

{

    process.DataFields["FirstName"].Value = tbFirstName.Text;

    process.DataFields["LastName"].Value = tbLastName.Text; 

}

 

private void UpdateActivityDataFields(ActivityInstanceDestination destination)

{

    destination.DataFields["Test1"].Value = tbTest1.Text;

    destination.DataFields["Test2"].Value = chkTest2.Checked; 


Forum|alt.badge.img+4
  • Author
  • September 27, 2007
Btw, when debugging I do see jcorrect values in both the process instance's datafields and activity instance's datafields just before the I do the update/release ...

Forum|alt.badge.img+4
  • Author
  • September 30, 2007

Hi,



The same thing happen if I set the activity's datafields in same code context as I open the process instance:



Connection.Open(connectionString);
WorklistItem worklistItem = Connection.OpenWorklistItem(serialNumber, "ASP", true, true);
worklistItem.ProcessInstance.DataFields["Task"].Value = "Test"; // This gets saved
worklistItem.ActivityInstanceDestination.DataFields["Check_Subtask"].Value = true; // This don't get saved
worklistItem.ProcessInstance.Update();
worklistItem.Release();
Connection.Close();


Please note that I can see that the datafields do get updated when I debug, but it seems that K2 don't save them when I do the update and release the worklist item.



Can someone (from K2?) confirm that what I'm trying to do should be possible and is working for them?



Sincerely,
Cato Antonsen
 


Forum|alt.badge.img+4
  • Author
  • October 1, 2007
I might add that what I'm trying to do is storing the state of several checkboxes on a client page. Only when all checkboxes are checked, the event is finnished and should continue to next action...

Forum|alt.badge.img+2
  • October 4, 2007

Hi Cato,


Which version of K2 [blackpearl] are you using? I remember this being a bug in one of the Beta versions. Please note that you can request an evaluation of K2 [blackpearl] RTM from K2.com if required. Also please ensure that you've installed K2 [blackpearl] Hotfix 1 if you are using RTM. Hope this helps.


Cheers,


Seb


Forum|alt.badge.img+4
  • Author
  • October 5, 2007
Has got a confirmation that this is a known issue - even in hotfix 1.

Forum|alt.badge.img+1
  • October 31, 2011

Was this issue resolved ?  I'm experiencing the same problem.


Forum|alt.badge.img+10
  • Nintex Partner
  • October 31, 2011

Hi,


The Update() method on the ProcessInstance object is only for administrative updates and requires the user executing it to have Admin rights on the process. This is not the recommended approach to save data fields from the client pages.


The better approach would be to use K2 Actions to save the data field values. If you want to save the data fields without moving the process on to the next activity, execute an Update action. If you want to save the data field values and complete the item so that the K2 process can continue, execute a Finish Action. This will save the data correctly.


Hope this helps!