Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎08-29-2022 02:24 AM
I need to check that the Hire Date is in the future or within 30 days (prior or past).
Writing a BR to check and set a configuration item to onboarding.
Solved! Go to Solution.
		1 ACCEPTED SOLUTION
	
		
			Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎08-29-2022 02:30 AM
Hi,
something like this
(function executeRule(current, previous /*null when async*/) {
	// Add your code here
	var nowTime = new GlideDateTime();
	nowTime.addDaysUTC(30);
	var nowTime1 = new GlideDateTime();
	nowTime1.addDaysUTC(-30);
	var currentTime = new GlideDateTime();
	var newHireDate = new GlideDateTime(current.u_date); // give the date field name here
	if(newHireDate.getNumericValue() > currentTime.getNumericValue() || (newHireDate.getNumericValue() > nowTime1.getNumericValue() || newHireDate.getNumericValue() < nowTime.getNumericValue())){
		// this means Hire Date is in the future or within 30 days (prior or past).
		// use your logic here
	}
})(current, previous);
Regards
Ankur
	Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
			
			
				
			
			
				
			
			
			
			
			
		Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
		1 REPLY 1
	
		
		
			
			
			
					
	
			Options
			
				
					
	
			
		
	- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
‎08-29-2022 02:30 AM
Hi,
something like this
(function executeRule(current, previous /*null when async*/) {
	// Add your code here
	var nowTime = new GlideDateTime();
	nowTime.addDaysUTC(30);
	var nowTime1 = new GlideDateTime();
	nowTime1.addDaysUTC(-30);
	var currentTime = new GlideDateTime();
	var newHireDate = new GlideDateTime(current.u_date); // give the date field name here
	if(newHireDate.getNumericValue() > currentTime.getNumericValue() || (newHireDate.getNumericValue() > nowTime1.getNumericValue() || newHireDate.getNumericValue() < nowTime.getNumericValue())){
		// this means Hire Date is in the future or within 30 days (prior or past).
		// use your logic here
	}
})(current, previous);
Regards
Ankur
	Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
			
			
				
			
			
			
			
			
			
		Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
