Tuesday, November 8, 2011

Don't allow complete appointment unless "Status" is empty

You can don't allow close appointment as completed or cancelled unless user don't specify necessary field. 
Use following script:
function closeAppointment()
{
 var CRM_FORM_SAVE_MODE_SAVEASCOMPLETED = 58;
 var CRM_FORM_SAVE_MODE_CLOSE = 5;
 if ((event.Mode == CRM_FORM_SAVE_MODE_SAVEASCOMPLETED) ||
    (event.Mode == CRM_FORM_SAVE_MODE_CLOSE))
 {
  var qualifiedstatus = Xrm.Page.getAttribute("new_qualifiedstatus");
  if (!IsNull(qualifiedstatus))
  {
   var option = qualifiedstatus.getSelectedOption();
   if (IsNull(option) || IsNull(option.value) || IsNull(option.text))
   {
    alert("Please provide a value for the Qualified Status!");
    document.all.new_qualifiedstatus.focus();
    event.returnValue = false;
    return false;
   }
  }
 }
}

No comments:

Post a Comment