- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 10:50 PM
Hi All,
I need to auto close a case when subject person's employment start date crosses one day. I have written below logic on before/update BR:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 01:44 AM
Hi @Rekha20
change the steps like below and try
var currentDate = new GlideDate();
gs.addInfoMessage("currentDate: " + currentDate);
var startDateTime = new GlideDateTime(employmentStartDate);
var startDate= startDateTime.getLocalDate();
gs.addInfoMessage("startDateTime: " + startDate);
var dateDifferenceInMs = startDate.getNumericValue() - currentDate.getNumericValue();
var dateDifferenceInDays =Math.ceil( dateDifferenceInMs / 24/ 60 / 60 / 1000);
gs.print(dateDifferenceInDays);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 03:15 AM
Hi @Rekha20
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response helpful.
Thanks,
Yaswanthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 11:47 PM
Check whether gs.dateDiff method works or not in your business rule
If yes then you need to get current date using gs.nowDateTime() method
If your emp_startdate is of type date then you need to split your current date as below-
var date = gs.nowDateTime();//current date
var date1 = date.split(" ");
var date2 = date1[0];
var diff = gs.dateDiff(emp_startdate,date2,true);//this gives diff in seconds,you can calculate the diff in days aslo
if diff==0//both dates are same
diff <0//emp start date is greater than current date
diff>0//emp start date is less than current date
Mark this answer as correct and helpful if it hepls
Thanks,
Manjusha Bangale