locked
Passing a value from a picklist to a Integer RRS feed

  • Question

  • Hi all,

    I am currently attemting to use a picklists DataValue to populate an integer field that i can use for a sum in a report.

    Ive tried a few different things and am not sure where to really go from here. Here are a few examples of what i have tried, any help would be greatly appreciated

    Trial 1

    var prod =  crmForm.all.new_percentoftimepicklist.DataValue;
    crmForm.all.new_percentoftime.DataValue = parsInt(prod);

    Trial 2

    var prod =  parsInt(crmForm.all.new_percentoftimepicklist.DataValue);
    crmForm.all.new_percentoftime.DataValue = prod;

    Trial 3

    int prod =  crmForm.all.new_percentoftimepicklist.DataValue;
    crmForm.all.new_percentoftime.DataValue = prod;

     

    I have tried other combinations using the parsint function and just am drawing a blank

     

    Thanks in advance

    Gordie

    Monday, April 5, 2010 1:34 PM

Answers

  • Hi,

    you can use like this

    var prod =  crmForm.all.new_percentoftimepicklist.DataValue;

    if(prod!="")

    crmForm.all.new_percentoftime.DataValue=parseInt(prod);

     It should work otherwise check this

    crmForm.all.new_percentoftime.DataValue=parseInt(prod).toString();


    Mahain
    • Proposed as answer by HIMBAPModerator Monday, April 5, 2010 1:44 PM
    • Marked as answer by gordier780 Monday, April 5, 2010 2:57 PM
    Monday, April 5, 2010 1:43 PM
    Moderator

All replies

  • crmForm.all.new_percentoftimepicklist.DataValue is an integer so you don't need to parse it.

    var prod =  crmForm.all.new_percentoftimepicklist.DataValue;
    crmForm.all.new_percentoftime.DataValue = prod;


    Blake Scarlavai - Sonoma Partners - http://www.sonomapartners.com/
    Monday, April 5, 2010 1:39 PM
  • Hi,

    you can use like this

    var prod =  crmForm.all.new_percentoftimepicklist.DataValue;

    if(prod!="")

    crmForm.all.new_percentoftime.DataValue=parseInt(prod);

     It should work otherwise check this

    crmForm.all.new_percentoftime.DataValue=parseInt(prod).toString();


    Mahain
    • Proposed as answer by HIMBAPModerator Monday, April 5, 2010 1:44 PM
    • Marked as answer by gordier780 Monday, April 5, 2010 2:57 PM
    Monday, April 5, 2010 1:43 PM
    Moderator
  • The DataValue of a picklist is already an integer.  There's no reason to parse it.  Also if new_percentoftime is really an integer field then doing .toString() would cause it to alert saying you can't set a string to an integer field.
    Blake Scarlavai - Sonoma Partners - http://www.sonomapartners.com/
    Monday, April 5, 2010 3:53 PM
  • Hi Blake,

    DateValue of a picklist is an integer value but not a integer type, it's a string type. so you have to parse it if you need to use it as integer.

    For your reference Check this

    http://msdn.microsoft.com/en-us/library/cc189837.aspx

     


    Mahain
    Tuesday, April 6, 2010 6:33 AM
    Moderator
  • Interesting.  I thought I tested passing the picklist value into an integer field but I must've used the wrong field.  Thanks Mahain for that correction.

    Blake Scarlavai - Sonoma Partners - http://www.sonomapartners.com/
    Tuesday, April 6, 2010 3:04 PM