locked
MSCRM 2011: Autopopulate Radio button default Values RRS feed

  • Question

  • I have a requirement like I need to auto populate the Radio button values based upon the picklist Value.
    Picklist Change Value(new_changeValue)
    Values are No=1 , NoValue=2 and Value=3

    Radio Button Section:

    3 radio buttons with different schema names and one text field.

    If the picklist Value = No all the Radio button values should auto populate No and text should be No value.
    If the Picklist Value = No Value then all the radio buttons and text values null.
    If the picklist Value = Value then Radio buttons value should be null and text value default to "Please Enter Value description"

    I have written code like this , Code is working for Onchange but when it comes to save the record value is not retaining onSave. Please let me know what I need to change the below code to retain the Save value.

    function value()
    
    {
    
    var optionset = Xrm.Page.getAttribute("new_changeValue").getValue();
    
    if(optionset == 1) //If selected Value is No
    
    {
    
    Xrm.Page.getAttribute("new_radiobutton1").setVisible(0);
    Xrm.Page.getAttribute("new_radiobutton2").setVisible(0);
    Xrm.Page.getAttribute("new_radiobutton3").setVisible(0);
    Xrm.Page.getAttribute("new_textdiscription").setVisible("No Value");
    
    }
    
    else if(optionset == 2) //If Selected Value is NoValue
    
    {
    Xrm.Page.getAttribute("new_radiobutton1").setVisible(null);
    Xrm.Page.getAttribute("new_radiobutton2").setVisible(null);
    Xrm.Page.getAttribute("new_radiobutton3").setVisible(null);
    Xrm.Page.getAttribute("new_textdiscription").setVisible(null);
    
    
    
    }
    else{
    Xrm.Page.getAttribute("new_radiobutton1").setVisible(null);
    Xrm.Page.getAttribute("new_radiobutton2").setVisible(null);
    Xrm.Page.getAttribute("new_radiobutton3").setVisible(null);
    Xrm.Page.getAttribute("new_textdiscription").setVisible("Please Enter Value Discription");
    }
    
    
    
    }
    Thanks,




    • Edited by Rahul-22 Wednesday, August 27, 2014 5:58 PM
    Wednesday, August 27, 2014 5:57 PM

All replies

  • Rahul,

    Well for starters, everywhere that you current have

    Xrm.Page.getAttribute(...).setVisible(...);
    

    should be

    Xrm.Page.getAttribute(...).setValue(...);
    

    Make that update and see if things start working a little better

    Wednesday, August 27, 2014 7:15 PM
  • hi Rahul,

    since you are trying to update the value of text box, you should use .setValue instead of .setVisible.

    regards,

    Jithesh

    Wednesday, August 27, 2014 9:29 PM
  • Jithesh,

    Thanks for your response.

    I have modified the Script . Onchange it is working fine.

    Suppose if I seleted the value No, 
    for this result of the Radio button are No
    if I changed the Radio button value No to Yes and saving the record value is setting as No only instead of Yes.
    How can I handle this by using the Script.. Please suggest me on this.

    Thanks,



    • Edited by Rahul-22 Thursday, August 28, 2014 6:43 AM
    Thursday, August 28, 2014 6:43 AM
  • I guess your triggering your script on save of form also so  just trigger on change.
    Thursday, August 28, 2014 7:34 AM
  • No I'm triggering my Script Onchage of picklist only...

    Thanks, Toushu

    Thursday, August 28, 2014 11:38 AM
  • readonly field's value does not save. Please check your logic as well, 1 and 2 are actual optionset values. Not the blank. Use ie debugging tool using F12 and get the actual value.

    please use true and false value to show and hide fields instead of 0 and null.

    regards.

    Jithesh


    Thursday, August 28, 2014 10:00 PM