Bite my bytes

What I learn by day I blog at night.

  Home :: Contact :: Syndication  
  935 Posts :: 6496 Comments :: 235 Trackbacks

Search

Most popular posts

Categories

My Projects

Archives

Stuff


Copyright © by David Vidmar
 
Contact me!
 
LinkedIn Profile
 
 
 

I started doing some MS CRM work and been googling about it A LOT. This is a problem I haven’t seen clearly described, so here is my take. Feel free to correct me or improve the solution!

This is a pretty common scenario: let’s say we have a pick list. If a value from this pick list is selected, we want to make sure, that some other field has a value.

Form OnLoad

// save original value, so we can do rollback in OnChanged event if necessary
originalValue =  crmForm.all.<my_picklist>.DataValue;

Picklist OnChange

var complaintStatus =  crmForm.all..<my_picklist>;
var closedDate = crmForm.all.<my_other_field>;

if (complaintStatus.DataValue != null) {
  if (complaintStatus.DataValue == "3") // closed
  {
    if (closedDate.DataValue == null)
    {
      alert("Closed Date value must be specified, if you want to set status to Closed.");
      event.returnValue = false;
      complaintStatus.DataValue =
originalValue;
      complaintStatus.SetFocus();
    }
    else
    {
     
originalValue = complaintStatus.DataValue;
    }
  }
}

Posted on Monday, February 16, 2009 2:42 PM | Filed under: Developement MS Dynamics CRM |

 

Feedback

# re: MS-CRM 4: How to validate field input based on other fields value in JavaScript 2/22/2010 9:48 AM Ryan
Nice topic. I applied it to other fields and it worked marvellously.

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: 
Please add 8 and 3 and type the answer here: