Solved

Date Validation on Field - Dynamics CRM 2011

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!

733 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