Skip to main content
I am getting this message in the K2.net 2003 Service Manager under errors, after I added a datafield to one of the process and do tests in the line from one event to another. The problem is that there is still old processes that must be completed and I must take this live for a request I am bussy with.

Can someone tell me what code can I use to test if the datafield exist before I set the field to a object
hi Stefaans,

are you aware that if you export a new version of your process, then any already existing process instances will continue to use the old version & only new instances will use your new process?

You could loop through the K2.ProcessInstanceDatafields collection & check the name of each to see if the one you are expecting exists before populating?
Wez_p

Do you have any sample code for looping through the K2.ProcessInstanceDatafields collection & check the name to see if it exist?
icon-quote.giflchoing:
Wez_p

Do you have any sample code for looping through the K2.ProcessInstanceDatafields collection & check the name to see if it exist?


we're actually looping through a property bag that we produced & then seeing if that exists in the K2 process datafields before attempting to populate it. something like this:

.GetType());
}
}

// finish the work item
clientTask.Finish();

//close the K2 connection
workflowConnection.Close();


EDIT: a quick search in the K2 help files for "datafields class" also came up with this:


foreach(SourceCode.K2ROM.DataField oDataField in oDataFields)
{
if(oDataField.Name == "MyDataFieldName")
{
oDataField.Value = "My New DataField Value";
strMetaData = oDataField.Value.ToString();
}
}


hope that helps,

Wes

Reply