Dynamic Required Fields - Using JScript for CRM 3.0

During a customer, sales or service lifecycle, requirements for data entry can change as a customer goes from being a prospect to a customer, from a cold opportunity to a hot opportunity, from a inquiry case to a system down case.

 

Using Jscript and a few minutes, here is a sample script that will allow you to have the fields required on a form change depending on where they are in their rating.

 

So a Cold Opportunity has NO required fields

A Warm Opportunity has the required fields of Estimated Close Date and Price List

A Hot Opportunity has required fields of the above PLUS Probability and Estimated Revenue.

 

Again, this is for DEMO Use. It has been tested and is for use only with our demo data. If you decide to use this on your own system, you do so at your own risk.

 

So this script needs to be attached to the Opportunity Rating Field. Refer to the IG on how to do this. The four fields we required should be attached to the script as dependencies.

 

Start Script Here ---

 

switch (parseInt(event.srcElement.DataValue, 10))

{

 

    /* Opportunity Rating Picklist */

    case 1:

        /* Hot */

        crmForm.SetFieldReqLevel("pricelevelid", 1);

        crmForm.SetFieldReqLevel("estimatedvalue", 1);

        crmForm.SetFieldReqLevel("estimatedclosedate", 1);

        crmForm.SetFieldReqLevel("closeprobability", 1);

        break;      

    case 2:

        /* Warm */

        crmForm.SetFieldReqLevel("pricelevelid", 1);

        crmForm.SetFieldReqLevel("estimatedvalue", 0);

        crmForm.SetFieldReqLevel("estimatedclosedate", 1);

        crmForm.SetFieldReqLevel("closeprobability", 0);

        break;

    case 3:

    /* Cold */

       crmForm.SetFieldReqLevel("pricelevelid", 0);

       crmForm.SetFieldReqLevel("estimatedvalue", 0);

       crmForm.SetFieldReqLevel("estimatedclosedate", 0);

       crmForm.SetFieldReqLevel("closeprobability", 0);

       break;

 

    /* All other values */

    default:

       crmForm.SetFieldReqLevel("name", 0);

       crmForm.SetFieldReqLevel("customerid", 0);

       break;

 

}