gs.datediff() in business rule with 'true' is not picking date difference in seconds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2019 04:07 AM
Hi Team,
var datediff = gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime(),true);
Above statement in business rule with 'true' is not picking date difference in seconds.You can find the entire business rule below.If I use the statement with false it is picking the date difference in dd:hh:mm correctly : var datediff = gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime(),false);
Please help in fetching the seconds from date diff as I need to fetch the days from seconds.
(function executeRule(current, previous /*null when async*/) {
calculateAge();
function calculateAge()
{
var datediff = gs.dateDiff(current.opened_at.getDisplayValue(), gs.nowDateTime(),true);
current.u_incident_age_in_days = datediff;
current.update();
}
})(current, previous);
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2019 04:23 AM
Hi Ramya,
Try this! You will get output in seconds.
var gdt1 = new GlideDateTime( current.opened_at);
var gdt2 = new GlideDateTime();
var datediff = gs.dateDiff(gdt1,gdt2,true);
Note: The gs.dateDiff() method is not available in scoped applications.
If my reply has helped you,Kindly click the Helpful button.
If my reply is the answer you were looking for, Kindly click the Accepted Solution button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2019 10:55 PM
Hi Lavanya,
Thanks for your response.
After updating the business rule as you said I am not getting incident age in seconds.
Thanks,
Ramya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2019 07:16 AM
What is the data type of the field u_incident_age_in_days
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2019 10:16 PM
Data type of u_incident_age_in_days is duration.