Input string was not in a correct format while converting into int using SharedVariables - MS CRM 4.0 RRS feed

  • Question

  • Hi All,

    I am getting the below error while I try to convert string to integer value

    int intemp=in.Parse(context.SharedVariables["VariableName"].ToString());

    context.SharedVariables["VariableName"].ToString() values is="334443.45"

    Error Message:-

    "Input string was not in a correct format"

    Any help greatly appriciated...



    Friday, March 14, 2014 5:02 AM

All replies

  • This just shows that you are trying to access a value from parameter named "343433.34" from SharedVariables. The actual value returned could be anything. Try adding the whole context.SharedVariables["343433.34"] into watch during debugging and see what it actually returns before trying to convert it to an int.
    Friday, March 14, 2014 6:05 AM
  • Thanks for your response! sorry, That was typo mistake. I have updated the query..
    Friday, March 14, 2014 8:34 AM
  • Hi Srikanth,

    If your value is in floating point (334443.45), you can't convert that to an integer. If you want to round it to the nearest integer, I suggest doing it as follows:

    int intemp=(int)Math.Round(float.Parse(context.SharedVariables["VariableName"].ToString()));

    Admin QuikView Solution for CRM 2013

    Friday, March 14, 2014 9:39 AM