Hope all is well everyone!
Im practicing CRM Dynamics development, on the 'Contact' quick create form, I'm trying to achieve making the emailaddress1 field mandatory/setrequired only.
Currently my function below is making all of the form fields mandatory on the 'Contact' quick create form which I don't want it to do, I just want to make 'emailaddress1' field setrequired only, any suggestions?
function SetRequiredLevel()
{
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
attributes[i].setRequiredLevel("required");
}
}
//Xrm.Page.getAttribute("emailaddress1").getValue();
XRM.Page is deprecated. You should use this form:
function displayName(executionContext)
{
var formContext = executionContext.getFormContext(); // get formContext
// use formContext instead of Xrm.Page
formContext.getAttribute("emailaddress1").setRequiredLevel("required");
}