Mutually exclusive checkbox fields in ms crm 4.0

Resposta Proposta Mutually exclusive checkbox fields in ms crm 4.0

  • quinta-feira, 17 de maio de 2012 08:57
     
     

    Hi,

    I have the below requirement

    There are two checkbox fields that are mutually exclusive and the user must select exactly one choice. In other words, clicking a non-selected checkbox field will deselect whatever other check box field was previously selected.

    Any help greatly appriciated!

    Thanks,

    Srikanth Reddy



Todas as Respostas

  • quinta-feira, 17 de maio de 2012 09:03
     
      Contém Código

    hi you need to write js,add a function on both the fileds.

    register this one on field1 event and vice versa on field2

    Xrm.Page.getAttribuet("filed2").setValue(false)
    
    Xrm.Page.getAttribuet("filed1").setValue(true);


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

  • quinta-feira, 17 de maio de 2012 09:23
     
     

    Thanks for your quick response! I need to implement this functionality in MS CRM 4.0.

    I don't think it will work OnChange event handler of the fields, how can i do ?

  • quinta-feira, 17 de maio de 2012 09:48
    Moderador
     
     Resposta Proposta

    Hello Srikanth,

    To implement it you can use OnChange event handler with following syntax:

    For first field:

    crmForm.all.<Second field here>.DataValue = !crmForm.all.<First field here>.DataValue;

    For second field:

    crmForm.all.<First field here>.DataValue = !crmForm.all.<Second field here>.DataValue;

    the this is that this script would be triggered only when checkbox will loose focus.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter


  • quinta-feira, 17 de maio de 2012 13:51
     
     

    Thanks for your response! I have tried in other way by attaching OnClick event to the checkbox field in OnLoad event of the form. It is working fine for me.

        crmForm.all.us_firstfield.onclick = function()

        {

            if (crmForm.all.us_secondfeld.DataValue==true)

            {

                crmForm.all.us_secondfeld.DataValue=false;

            }

        }

       

       

  • quinta-feira, 17 de maio de 2012 14:00
    Moderador
     
     Resposta Proposta Contém Código

    Thanks for your response! I have tried in other way by attaching OnClick event to the checkbox field in OnLoad event of the form. It is working fine for me.

        crmForm.all.us_firstfield.onclick = function()

        {

            if (crmForm.all.us_secondfeld.DataValue==true)

            {

                crmForm.all.us_secondfeld.DataValue=false;

            }

        }

       

       

    Unfortunately your code is not full. Following code will work without issues:

    crmForm.all.us_firstfield.onclick = function()
    {
    	crmForm.all.us_secondfeld.DataValue = !crmForm.all.us_firstfield.DataValue;
    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter