tags:

views:

22

answers:

1

I have added javascript for reverse the items in the picklist (rating) to the opportunity entity. It is done. but when I am filling the data and saving it, it is not saving the selected item from the rating picklist to the database. What do I have to do?

var oField = crmForm.all.opportunityratingcode;
var items = oField.options.length;
var arrTexts = new Array(items);
var arrValues = new Array(items);

for(i=0;i<items;i++)
{
    arrTexts[i]=oField.Options[i].Text;
    arrValues [i]=oField.Options[i].DataValue;
} 

for(i=0;i<=items;i++)
{
    oField.DeleteOption(i);
}

for(j=items;j>0;j--)
{
    var oOption1 =oField.Options;
    oOption1.Text=arrTexts[j-1];
    oOption1.DataValue= arrValues [j-1];
    oField.AddOption(oOption1.Text,oOption1.DataValue);
    alert(oOption1.DataValue);
}
A: 

Sounds like you need to add a .ForceSubmit in the onSave of the form. This forces CRM to save attribute data changes that you have made with JavaScript.

e.g.

crmForm.all.attribName.ForceSubmit = true;

Check the CRM SDK here: http://technet.microsoft.com/en-us/library/cc189831.aspx

ABC123
Thanks for reply. Got the answer: Actually it is the matter of selected value previously. means while page loading , the picklist populates the default sequence of the options. ok? and sets the default index as selected. thus before all code to starts have to take the selected value in the var as:var currentSelected= oPiklst.SelectedIndex;and assign the the rest of the code to again picklist asoPiklst.SelectedIndex=currentSelected;ok. In fact i was saving but while populating , it sets default index.
Lalit