dateDiff is not allowed in scoped applications, what is the alternate way of finding the difference between two "DATE" fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 11:40 AM
Hi All,
We have a requirement to modify the Priority of an HR Case (this becomes a scoped application) based on 2 catalog variables in the record producer.
Requirement :
"Effective Date" is today or in the past AND "Is Pay Changing" = "Yes", then the priority should change from moderate to high
My Record Producer's Script
var eff_date = producer.effective_date;
var diff = gs.dateDiff(eff_date, GlideDate(), true);
var answer = '';
var pay_answer = '';
if (diff >= 0) {
answer = 'true';
}else {
answer = 'false';
}
var pay_answer = '';
if (producer.is_pay_changing == 'Yes') {
pay_answer = 'true';
} else {
pay_answer = 'false';
}
if (answer == 'true' && pay_answer == 'true') {
current.priority = 2;
} else {
current.priority = 3;
}
I get an error saying dateDiff is not allowed in sn_hr_sp. Use GlideDateTime.subtract() instead.
Can anyone assist me on this as our HR catalog is using a Date variable and GlideDateTime.subtract() is a Date/Time function.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2022 01:45 PM
Hello Shraddha,
You can use the below script this should work for the mentioned requirement.
---------------------------------