web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 4.0 : picklist values not saving !

(0) ShareShare
ReportReport
Posted on by 1,720

Hi all,

I have binded two picklists dynamically through javascript onLoad event for a CRM form.

In onLoad everything is working. But while saving, the picklist values are not saved in database.

Anybody have an idea why it behaves so ?

*This post is locked for comments

I have the same question (0)
  • Mariusz Profile Picture
    on at
    Re: CRM 4.0 : picklist values not saving !
    If you pick list is loaded with onLoad function, you have to use onSave() and save crmForm.all.new_field.SelectedText to some other field (might be hidden). Than ooLoad check if that hidden field is empty, if so just load picklist if not load picklist and select correct one.
  • Binu Kumar S Profile Picture
    1,720 on at
    Re: CRM 4.0 : picklist values not saving !

    Thanks for your reply.

    Will try and let you know

  • Binu Kumar S Profile Picture
    1,720 on at
    Re: CRM 4.0 : picklist values not saving !

    hi,

    i don't want to repopulate the picklist on onLoad or so !,

    i just need to save the selected value of picklist to the CRM database (which is not happening now)

    its being inserted as NULL in database. why so ?

  • Kenny Vaes Profile Picture
    345 on at
    Re: CRM 4.0 : picklist values not saving !

    Is the picklist disabled in the crmForm?
    If so you need to call the ForceSubmit property after assigning it.

    Example:
    crmForm.all.new_picklist.DataValue = 2;
    crmFrom.all.new_picklist.ForceSubmit = true;

  • Binu Kumar S Profile Picture
    1,720 on at
    Re: CRM 4.0 : picklist values not saving !

    No, the picklist is not disabled.

    here is what happens

    1) i load the picklist values to the picklist in onLoad event (javascript) using AddOption method of picklist

    2) It is populating the values and text as i expected

    3) when i select an option from picklist and press the save/save&close/save&new, the picklist options are cleared and in database its inserting the value as NULL.

    4) Though when i tried an alert in onSave (javascript) iam getting the DataValue too....I don't understand whats happening there ?

    5) if i give static values in picklist its working. But i can't do it in my case !

    any idea ?

  • Kenny Vaes Profile Picture
    345 on at
    Re: CRM 4.0 : picklist values not saving !

    Ah, this type of behaviour is not supported in CRM 4.0.

    In the SDK it even states:

    To define valid options you must modify the Attribute definition via the Customization tools or the metadata APIs. You should not create new picklist options programmatically in form event code. Manipulating the Options array is the most common solution to ensure valid picklist data.

    And a remark:

    All the valid picklist options are defined in the Microsoft Dynamics CRM Metadata. When a record is saved with an invalid picklist option selected the field will be set to the default value and the invalid data will be lost.

    As a workarround you can maybe create a bunch of dummy options via the customizations tool in CRM and then just replace the text of each option and delete the unwanted ones in the onLoad event?

     Just a suggestion. 

  • Mariusz Profile Picture
    on at
    Re: CRM 4.0 : picklist values not saving !

    As I sugest before. Create one more dummy hidden text field which will store selecttext from your dynamic dropdown list. And at the time of loading values to that list (onLoad) check if that field is empty then do nothing if is not set selecttext=dummy textbox. You need one more function onChange assign to Dropdown list which will copy selectedtext to dummy textbox.

     Hope that helps.

  • Binu Kumar S Profile Picture
    1,720 on at
    Re: CRM 4.0 : picklist values not saving !

     Thanks dear Friends for your valuable suggestions, All the idea are good.

    Yesterday i tried with the below option and i got succcessfull. The steps follwed are:

    1. Instead of picklist type i declared the attribute as simple text
    2. On the onLoad event i created a html select control dynamically and binded the values from CRM database.
    3. i added this SELECT control to the innerHTML of our attribute
    4. hide our CRM attribute (so now our CRM attribute is hidden and SELECT control is visible)
    5. On onSave event i loop through the SELECT control and get the selected item
    6. Set the selected item's value to the hidden CRM attribute
    7. So while saving the correct selected value will be saved to database
    8. SUCCESS

    Limitations:

    • Can't declare the CRM attribute as business required
    • don't get any events like onChange for created SELECT control

    Refered links are:

    http://forums.microsoft.com/Dynamics/ShowPost.aspx?PostID=2839313&SiteID=27
    http://www.stunnware.com/crm2/topic.aspx?id=JS1

    Cheers

  • bhavika patel Profile Picture
    40 on at
    Re: CRM 4.0 : picklist values not saving !

    Hello,

    I have managed to create picklist dynamically from a text field.

    Now I need to fire onChange() event on the same. I am not ablr to do this.

    Have any one got any work around for this?

    please help me out.

    Thank you

    -Bhavika Patel

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    Re: Re: CRM 4.0 : picklist values not saving !

     Hi, Bhavika.

     Paste your code here, please, and i'll try to help you.

    If you dinamically create a Select control to attach event onto it, try following code (for exaple control id is 'Select1'):

    var ctrl = document.getElementById('Select1');

    if (ctrl != null)
    {
    ctrl.attachEvent('onchange', Select1_Onchange);
    function Select1_Onchange()
    {
    alert(ctrl.value);
    }
    }

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans