locked
Putting values from dropdown lists into a nvchar attribute RRS feed

  • Question

  • Hi,

    Here comes a newbie question (i think).

    I work on the Opportunity form.
    Here can the users choose from picklist what sort of product family the the opportunity involves.

    So they can choose for example,
    Productfamily 1 in one particulary picklist
    Productfamily 2 in one other particulary picklist

    Heres what i want to do. i would like to "sum" the values from the two diferent picklists into a new attribute
    The result in the new attribute should be. "Productfamily1, Productfamily2"

    The reason why i want this is becuase i want a cleaner overview in my view. ofcourse i could ad the two droplists attributes to the view but this looks so messy and takes alot of space.

    I guess this should be quite simply to manage with a script?

    All help is appriciated or even links to places where i can learn more about this kind of changes.

    Best Regards

    Joel 
    Thursday, February 11, 2010 8:40 AM

Answers

All replies


  • You can see the below example from sdk on how to access the picklist, you can then add it or do whatever you want.

    crmForm.all.newfiled.DataValue = parseInt(crmFrm.all.picklistField1.DataValue) + parseInt(crmForm.all.picklistfield2.DataValue);

    Example

    The following code example shows how to use a field of type Picklist. Note that when you add an option to a Picklist, the option must already exist in the set of possible options.

    var oField = crmForm.all.SOME_PICKLIST_FIELD_ID;
    
    // Capture the fourth option
    var oOption = oField.Options[4];
    
    // Show how many options are available
    alert("Original length :"+ oField.Options.length);
    
    // Set the field to the first option by value
    oField.DataValue = 1;
    
    // Show the text for the first option
    alert(oField.SelectedText);
    
    // Remove the fourth option
    oField.DeleteOption(4);
    
    // show the new length
    alert("New length :"+ oField.Options.length);
    
    // Restore the fourth option
    oField.AddOption(oOption.Text, oOption.DataValue);
    
    // Show the restored length
    alert("Restored length :"+ oField.Options.length);
    Thursday, February 11, 2010 8:47 AM
  • Hi, Joel.

    Try to use following script:

    crmForm.all.<concatenate field>.DataValue = (crmForm.all.<picklist 1>.DataValue == null ? '' : (crmForm.all.<pickslist1>.SelectedText + ', ')) + (crmForm.all.<picklist 2>.DataValue == null ? '' : crmForm.all.<pickslist2>.SelectedText);
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный) free counters Locations of visitors to this page
    Thursday, February 11, 2010 9:15 AM
    Moderator
  • Thanks you both, i will look into this!

    Best Regards
    Joel
    Thursday, February 11, 2010 10:08 AM
  • Andriy a33ik Butenko, it worked out great.

    I tried to also pick up a value från another nvchar attribute, but i guess theres something else which needs to be done becuase i recived "Undefined"

    Best Regards
    Joel
    Thursday, February 11, 2010 2:17 PM