K2.SerialNumber throwing "input string was not in a correct format" error in Server Event

  • 17 April 2014
  • 4 replies
  • 1 view

Badge +1

 

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?

 


4 replies

Badge +5

Hi, tham


 


Could you please look at the links below which was on the previous community post where someone had a similar issue to yours, please try his suggested solution to see if that fix the error you have.


 



 


Regards


 


Julia

Badge +3

What is the type of the data field?

 

It could be due the fact that you are storing a text value (Serial Number) to an integer data type.

Badge +8

What KennyC said.

Badge +1

Thanks KennyC , that was exactly it! I changed the Datafield to a string and it worked.

Reply