CRM – Making field required based on Lookup Value, NOT picklist…

I posted this question to the CRM Forums here and got some good feedback from Rhett Clinton.

if(crmForm.all.new_salesstageid.DataValue != null && crmForm.all.new_salesstageid.DataValue[0].name != "1")
crmForm.SetFieldReqLevel("new_projectmanagerid", 1);

else

crmForm.SetFieldReqLevel("new_projectmanagerid", 0);

And here is an example that works with multipe options

if(crmForm.all.new_salesstageid.DataValue != null) {

    switch(crmForm.all.new_salesstageid.DataValue[0].name) {
        case "1":
        case "2":
            crmForm.SetFieldReqLevel("new_projectmanagerid", 1);
            break;
        default:
             crmForm.SetFieldReqLevel("new_projectmanagerid", 0);
      break;
    }

}
else
{
    crmForm.SetFieldReqLevel("new_projectmanagerid", 0);
}

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>