locked
CRM Field Validation RRS feed

  • Question

  • Folks:

    I have a contact form with the following fields:

    Full Name:

    Company:

    Contact:

    EmailID:

    Send Communication:

     

    The 'Send Communication' is a radio button with YES/NO. The 'EmailID' field is not a Business Required field. Is it possible that whenever the 'Send communcation' radio button is set to 'YES' the 'EmailID' field should be made as a Required field and when the 'Send Communication' button set to 'NO' the EmailID field should not be a required field ?

     

    Thanks !

    Thursday, January 27, 2011 9:12 PM

Answers

  • Hi,

    You will need to do something like this in this ...

    In the onChange event of your "Send Communication" attribute:

    // If "Send Communication" is set to "Yes"
    if(crmForm.all.new_sendcommunication.DataValue == true)
        {
        // Make "Email ID" required
        crmForm.SetFieldReqLevel("new_emailid", 2);
        }
    else
        {
        // Make "Email ID" NOT required
        crmForm.SetFieldReqLevel("new_emailid", 0);
        }

    In the onLoad event of your form:
    You will need the following to ensure that your "Email ID" is required if "Send Communication" is ticked when the form is first loaded.

    // Trigger the "Send Communication" onChange to set form defaults
    crmForm.all.new_sendcommunication.FireOnChange();

    (make sure you replace "new_sendcommunication" and "new_emailid" with you actual field schema names)

    Hope this is what you are after!

    Thanks,
    Maryse

     


    The xRM Architect:
    Thursday, January 27, 2011 9:59 PM

All replies

  • Hi,

    You will need to do something like this in this ...

    In the onChange event of your "Send Communication" attribute:

    // If "Send Communication" is set to "Yes"
    if(crmForm.all.new_sendcommunication.DataValue == true)
        {
        // Make "Email ID" required
        crmForm.SetFieldReqLevel("new_emailid", 2);
        }
    else
        {
        // Make "Email ID" NOT required
        crmForm.SetFieldReqLevel("new_emailid", 0);
        }

    In the onLoad event of your form:
    You will need the following to ensure that your "Email ID" is required if "Send Communication" is ticked when the form is first loaded.

    // Trigger the "Send Communication" onChange to set form defaults
    crmForm.all.new_sendcommunication.FireOnChange();

    (make sure you replace "new_sendcommunication" and "new_emailid" with you actual field schema names)

    Hope this is what you are after!

    Thanks,
    Maryse

     


    The xRM Architect:
    Thursday, January 27, 2011 9:59 PM
  • In the onLoad event of the contact form, do this:

    crmForm.all.name of Send Communication field.DataValue == true;

     

     

    In the onSave event of the contact form, do this:

    if (crmForm.all.name of Send Communication field.DataValue == true)   

    {
      alert("EmailID is required in order to save");
      return false;
      }

    else

    {
      return true;
      }
    }

    You just have to make sure that you set the default value for the 'Send Communication' field.  Also, where I have name of Send Communication field, you will of course change this to what you have actually named the field.  Hope this helps

    Friday, January 28, 2011 2:42 AM
  • Yes you can.

    Just put the following code in the OnChange event of "Send Communication" attribute.

    Also just attache the OnChane event of this in the OnLoad of form.

    Make sure the attribute schema names.

    #1 Put the following on OnLoad means just call the OnChange of "Send Communication". so u can reuse the code.

    if (crmForm.all.new_sendcommunication!= null) {
        crmForm.all.new_sendcommunication.FireOnChange();
    }

    #2 Now put the following in the OnChange of "Send Communication" attribute.

    if(crmForm.all.new_sendcommunication != null){
        if(crmForm.all.new_sendcommunication.DataValue == true) //means if yes
        {
            // Make "Email ID" required
            crmForm.SetFieldReqLevel("new_emailid", 2);
        }
        else // means no
        {
            // Make "Email ID" NOT required
            crmForm.SetFieldReqLevel("new_emailid", 0);
        }
    //for your information 1 is for Business Recomended
    }

     

    Hope this will fullfill your requirement.

     


    yes.sudhanshu

    http://bproud2banindian.blogspot.com
    http://ms-crm-2011-beta.blogspot.com
    Friday, January 28, 2011 3:47 AM
  • Thanks All... It works !!!!!
    Friday, January 28, 2011 1:43 PM
  • hi sqldba20,

     

    if any ans helps you just make it answered.

    which will help , if any one is searching they can see this question has a solution which helped the person who has asked.

     

     


    yes.sudhanshu

    http://bproud2banindian.blogspot.com
    http://ms-crm-2011-beta.blogspot.com
    Monday, January 31, 2011 3:19 AM
  • hello, 

    well i am really new with crm 2011 and  ive been having problems customizing it due to the fact that i do not know how or where do i put code in it. 

    I know how to do things on code but i need really someone to help me with where or how can i access to th OnChange and other methods of the entities and forms in order to be able to custom the solution correctly.

    Sorry for asking this in here but i do not know where to go 

    Thanksss

    Tuesday, March 13, 2012 9:23 PM
  • John_Rohr,

    Pls refer to the following post for "Form Scripting in CRM 2011"

    http://crmconsultancy.wordpress.com/2010/10/19/form-scripting-in-crm-2011/

    Hope you can get some understanding since it's showing step by step with screenshots.

    Tuesday, March 20, 2012 3:32 PM