- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2023 08:38 AM
On our Problem form, we have a State field with 3 choices (Open, Work in Progress, Closed). Since we don't have the 'Close Problem' button enabled on the form, when an agent wants to close the Problem they just change the State to Closed. Because of this, the 'Closed' field has no value/date. What I'd ultimately like to do, is have\create an additional field on the Problem table called 'Resolved Time'. This would be the difference between the 'Created value and the 'Closed' value. For this to happen, I need to expose the 'Close Problem' button on the Problem form. When they want to close the Problem, they would click the 'Close Problem' button. This would then place the Closed time in the Closed field. However, if you close the Problem using the 'Close Problem' button, the State does not change to Closed. I need assistance with:
1. How do I configure the State to change to 'Closed', if the the 'Close Problem' button is clicked?
2. How do I configure a new field ('Resolved Time') to calculate the difference between the 'Created' value and the 'Closed' value? Business Rule Advanced script? If so, can you provide sample code?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2023 07:06 AM - edited ‎04-21-2023 07:07 AM
Update to the script:
var createdOn = current.sys_created_on.getDisplayValue();
var createdDateTime = new GlideDateTime();
createdDateTime.setDisplayValue(createdOn);
var dur = GlideDateTime.subtract(createdDateTime, new GlideDateTime());
current.u_resolved_time = dur;
current.closed_at = new GlideDateTime();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2023 09:39 AM
You should be able to accomplish this without turning on the button with a business rule. Something like this:
var nowDate = new GlideDateTime();
var openDate = new GlideDateTime(current.sys_created_on);
var dur = GlideDateTime.subtract(openDate, nowDate);
//then use this dur in your time field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2023 06:51 AM
Hi Kristen,
With this BR, the agent can close the Problem by selecting the Closed State? Meaning, it will then populate the Closed field with a date/time (which it doesn't now)? When you say time field, would it be the new field I want to create (Resolution Time)? How would the time calculated in the BR populate to this new field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2023 09:52 AM
Hi Kristen,
So, what would this BR do? After an agent selects the State as Closed, it would add the date/time in the Closed field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2023 07:37 AM
Yes, it would allow you to calculate the time and put it into your duration field when they move the problem to a closed state.