locked
MSCRM 2011 : Two Option set value RRS feed

  • Question

  • Hi,

    I have a one Optionset ( new_Optionset ) and one radio button Gender(new_gender)
    Optionset Values = Yes (100000000) and No(100000001)

    While selecting upon the value in the Optionset if value =  yes then  Gender radio button(two optionSet) = null
    If Optionset Value = No then Gender = No

    I have written code like this

    Var Value = Xrm.Page.getAttribute("new_Optionset").getValue()

    if (Value == 100000000) {
        Xrm.Page.getAttribute("new_gender").setValue(null);
    }

    if (Value == 100000001) {

    Xrm.Page.getAttribute("new_gender").setValue(0);

    }

    when I'm calling this function in Onload its working fine for Optionset value = Yes and  Radio buttons are = null  but when I'm selecting the value one of the Radio button value and saving the record its still showing as null instead of saving value.

    Please let me know how to resolve this

    Thanks,




    • Edited by Rahul-22 Thursday, March 20, 2014 8:35 AM
    Thursday, March 20, 2014 8:33 AM

Answers

  • Hi Rahul,

           Please change the code to following:

    Var Value = Xrm.Page.getAttribute("new_Optionset").getValue();

    var genderValue = Xrm.Page.getAttribute("new_gender").getValue();

    if (Value == 100000000 && genderValue != null) {
        Xrm.Page.getAttribute("new_gender").setValue(null);
    }

    if (Value == 100000001 && genderValue !=0) {

    Xrm.Page.getAttribute("new_gender").setValue(0);

    }

    The reason is onload loads after onsave so onload is clearing the value again.


    Hope this helps.
     
    -----------------------------------------------------------------------
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

     
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    • Marked as answer by Rahul-22 Thursday, March 20, 2014 10:13 AM
    Thursday, March 20, 2014 9:35 AM

All replies

  • Hi Rahul,

           Please change the code to following:

    Var Value = Xrm.Page.getAttribute("new_Optionset").getValue();

    var genderValue = Xrm.Page.getAttribute("new_gender").getValue();

    if (Value == 100000000 && genderValue != null) {
        Xrm.Page.getAttribute("new_gender").setValue(null);
    }

    if (Value == 100000001 && genderValue !=0) {

    Xrm.Page.getAttribute("new_gender").setValue(0);

    }

    The reason is onload loads after onsave so onload is clearing the value again.


    Hope this helps.
     
    -----------------------------------------------------------------------
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

     
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    • Marked as answer by Rahul-22 Thursday, March 20, 2014 10:13 AM
    Thursday, March 20, 2014 9:35 AM
  • Minal,

    Thanks for your quick response its working fine.


    • Edited by Rahul-22 Thursday, March 20, 2014 10:13 AM
    Thursday, March 20, 2014 10:13 AM