glide duration field not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2024 09:33 PM
Hi everyone, I want to populate a new created field named 'on hold duration' in the incident form, when the state of incident is changing to on hold. I want the new field to hold the duration of the incident being in on hold state.
Here is the code that I wrote for the 'after' business rule when state is 'on hold':
var onHoldMetric = new GlideRecord('metric_instance');
var present = new GlideDateTime();
gs.info(onHoldMetric.id.getDisplayValue + " " + present);
onHoldMetric.addEncodedQuery('definition=35f2b283c0a808ae000b7132cd0a4f55^value=On Hold^end=NULL')
onHoldMetric.query();
while(onHoldMetric.next()) {
if(onHoldMetric.id == current.sys_id) {
var startOnHold = new GlideDateTime(onHoldMetric.start);
current.u_on_hold_duration = GlideDateTime.subtract(startOnHold, present);
}
}
this is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2024 10:29 PM
@kushagrasingh You can create as below using GlideFunction() using function field and define the fields for calculation.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.