Hi,
I am using K2 Blackpearl 4.6.7 and I am trying to store the serial number into a datafield from a Server Event as follows:
public void Main(Project_b842c4eda6074063bb5f315594e814b2.EventItemContext_67b31645691548e39c23bfe91a7bd1ad K2)
{
K2.Synchronous = false;
// int serialNumber = Convert.ToInt32(K2.SerialNumber);
K2.ProcessInstance.DataFields["SerialNumber"].Value = K2.SerialNumber;
}
However I get the error "input string was not in a correct format" under error profiles in workspace for the Activity containing the server event. The error is not thrown when I set the datafield to a static number e.g.
K2.ProcessInstance.DataFields["SerialNumber"].Value = 4;
This makes me think the issue is with K2.SerialNumber. I have tried to debug this by Attaching to the Process in Visual Studio 2012 but the debugger wants me to idenfigy the file Project_b842c4eda6074063bb5f315594e814b2.EventItemContext_67b31645691548e39c23bfe91a7bd1ad.cs which does not exist.
I have managed to view the datafields when trying to access the ServerEvent from Code but it is always set to 0. The code to access the ServerEvent is as follows:
ProcessInstance processInstance = connection.OpenProcessInstance(processId);
String serialNumber = processInstance.DataFields["SerialNumber"].Value.ToString();
Does anyone have any idea how I get the ServerEvent to set the serial number in a datafield without the error I am getting?