difference of two field need to store in another field in incident form
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 01:30 AM
Hello All,
I have the below requirement.
I have three types field.
Here the total duration is not giving the correct result. I have written the below before business rule script.
(function executeRule(current, previous /*null when async*/) {
var startTime = current.u_onhold_duration.dateNumericValue();
var endTime = current.u_onhold_end_time.dateNumericValue();
current.u_total_duration.setDateNumericValue(endTime-startTime);
})(current, previous);
but it is not giving the correct result.
Can anyone please help me on this.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 04:05 AM
Can you try this? Duration fields are a bit trickier than date/time fields.
(function executeRule(current, previous /*null when async*/) {
var startTime = current.u_onhold_duration.getValue();
var endTime = current.u_onhold_end_time.getValue();
var totalDurationInSeconds = parseInt(endTime) - parseInt(startTime);
// Convert the result back to a duration format or store it as needed
current.u_total_duration.setValue(totalDurationInSeconds.toString());
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 10:02 PM
@Mark Manders It is not giving any result.Not getting calculated.