Solved

Date Validation on Field - Dynamics CRM 2011

Posted on 2016-09-19
4
64 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now