One of the features of Microsoft Dynamics CRM 2011 is the ability to set requirement levels of a field. There are three options:
None
Recommended
Required
I always smile at the recommended option, as I actually think it’s a waste of time – Just my opinion.
What would be useful sometimes though is that a field requirement might change based on a choice somewhere else on the CRM form
While Microsoft Dynamics CRM doesn’t allow for this out of the box, there is a nice way to accomplish this by way of scripting. The code below will assign the requirement level of Required on the field ‘prioritycode’:
function setrequire()
{
Xrm.Page.getAttribute("prioritycode").setRequiredLevel("required");
}
This in itself isn’t particularly useful. If all we’re going to do is change a requirement level onload, then you might as well set it at the field level anyway. What we want to do is change it based on a choice on another field.
You could place the above code within an ‘If’ statement so if a certain choice is made, then the requirement level of a field is changed:
function setrequire()
{
var type = Xrm.Page.getAttribute("new_natureofenquiry").getSelectedOption().text;
if (type == "Option1")
{
Xrm.Page.getAttribute("prioritycode").setRequiredLevel("required");
}
else
{
}
}
The code above initially gets the value of a field (Text Value in this case) and if it meets a criteria (= “Option1”) then changes the requirement level.
Enjoy.
Rob
0 comments:
Post a Comment