Solved

Date Validation on Field - Dynamics CRM 2011

Posted on 2016-09-19
4
132 Views
Last Modified: 2016-09-20
Hi,

I have created a Date field in the Activity Entity in CRM 2011 and need to set a validation so that a user cannot enter a future date.

Please advice how to set this up.

Thanks
GFC
0
Comment
Question by:GulfIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 19

Assisted Solution

by:Rikin Shah
Rikin Shah earned 500 total points
ID: 41806122
Hi,

You can use this function on change event of your date field. Just need to change the date field logical name on the first line of the function.

function checkFutureDate(){
	var enteredDate = Xrm.Page.getAttribute("<date field logical name>").getValue();
	var currentDate = new Date();
	currentDate.setHours(0, 0, 0, 0);

	if (enteredDate > currentDate) {
		alert("Future date is not allowed.");
		return false;
	}
}

Open in new window

0
 

Author Comment

by:GulfIT
ID: 41806243
It gave a warning but accepted the value.

Is there anyway to block it from accepting the value if its future date.
0
 
LVL 19

Accepted Solution

by:
Rikin Shah earned 500 total points
ID: 41806255
Add following line before "return false;" statement in the function.

Xrm.Page.getAttribute("<date field logical name>").setValue(null);

Open in new window

1
 

Author Closing Comment

by:GulfIT
ID: 41806270
Thanks it worked.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question