locked
IF Statement getValue RRS feed

  • Question

  • Folks:

    I have 4 columns with 'Yes' and 'No' toggle(Option). I would like to make emailID column required if ANY of the 4 columns has a toggle set to YES. How do I include OR in the If statement to check because this is giving an error.

     if(Xrm.Page.getAttribute("COLUMN1").getValue() == true) ||
     if(Xrm.Page.getAttribute("COLUMN2").getValue() == true) ||
     if(Xrm.Page.getAttribute("COLUMN3").getValue() == true) ||
     if(Xrm.Page.getAttribute("COLUMN4").getValue() == true)
        {
        // Make "Email ID" required
        Xrm.Page.getAttribute("emailIDColumn").setRequiredLevel("required");
        }
      else
        {
        // Make "Email ID" NOT required
        Xrm.Page.getAttribute("emailIDColumn").setRequiredLevel("none");
        }

    Thanks !

    Thursday, January 15, 2015 4:02 PM

All replies

  •  if(Xrm.Page.getAttribute("COLUMN1").getValue() == true || 
      Xrm.Page.getAttribute("COLUMN2").getValue() == true ||
      Xrm.Page.getAttribute("COLUMN3").getValue() == true ||
      Xrm.Page.getAttribute("COLUMN4").getValue() == true)
         {
         // Make "Email ID" required
         Xrm.Page.getAttribute("emailIDColumn").setRequiredLevel("required");
         }
       else
         {
         // Make "Email ID" NOT required
         Xrm.Page.getAttribute("emailIDColumn").setRequiredLevel("none");
         }
    Try the above, you only need to specify 'if' once

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thursday, January 15, 2015 4:07 PM
    Moderator