- 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-16-2023 11:37 PM
Hi @Rekha20
use date difference like below
var daysSinceStart =gs.dateDiff(startDateTime.getDisplayValue(), currentDate.getDisplayValue(), false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 11:40 PM
Hi @yaswanthi2
Thanks for response. as this is in scoped application so getting error like: Function dateDiff is not allowed in scope sn_hr_le. Use GlideDateTime.subtract() instead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 11:46 PM
You can use below code for date subtract in scoped application
var daysSinceStart= GlideDateTime.subtract(startDateTime.getDisplayValue(), currentDate.getDisplayValue());
gs.info(daysSinceStart.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 11:50 PM
HI @yaswanthi2
Now getting error : exception: org.mozilla.javascript.EvaluatorException: Can't find method com.glide.script.fencing.ScopedGlideDateTime.subtract(string,string).