Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date Validation on Field - Dynamics CRM 2011

Posted on 2016-09-19
4
Medium Priority
?
224 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 20

Assisted Solution

by:Rikin Shah
Rikin Shah earned 2000 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 20

Accepted Solution

by:
Rikin Shah earned 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

963 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