HOW TO: Change fileld requirement level, Bypass valiation in MS CRM 2011

MS CRM 2011 provides api to change requiremnt level of fields of the form (this is a new feature of crm 2011).

Xrm.Page.getAttribute("my_fieldname").setRequiredLevel("none");
Xrm.Page.getAttribute("my_fieldname").setRequiredLevel("required");
Xrm.Page.getAttribute("my_fieldname").setRequiredLevel("recommended");

If you need to bypass validation during saving of the form use function below. Call it during form load. Note! This script is not supported by Microsoft CRM SDK and it could couse errors. I used it on lead form without any trouble.

function BypassValidation()
{
$get("crmForm").BypassValidation = true;
}

1 comments: