Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks


Most popular posts
in last 180 days


My Projects



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.DataValue;

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


# 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.

Comments have been closed on this topic.