- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-11-2018 06:26 AM
I was looking through the community for a post that would help me with a problem I ran into recently.
In our env't, we allow a user to create a PRB, work the PRB in an 'Open' state. Once the PRB is finished, the user moves it to 'Closed/Resolved'. In this case, the duration value calculates as expected
In some cases, the customer rejects the work done to fulfill the PRB. In this case, the PRB is set to open and the duration clock should start counting again.
But...how do I add the initial duration to the new duration after the PRB has been reopened?
I found some great scripts in the community but nothing that would solve my issue completely. Here is an example.
So here's what I did to solve my issue:
First I created a new business rule 'problem_reopen'
Table: Problem
Active: True
Advanced: True
When to run: Closed is empty
Script:
if (current.problem_state < 4 && current.active == false) {
current.active == true;
current.opened_at = gs.nowDateTime(); //since we still have the created_on date, i am updating the opened_at date to the current time. This will be used in another business rule
gs.log("Problem reopened: " + current.number);
}
Next, I created a new business rule 'reclose_problem_ticket'
Table: Problem
Active: True
Advanced: True
When to run: Closed is not empty
Script:
if (current.problem_state == 4) {
current.active == false;
current.closed_at = gs.nowDateTime();
current.calendar_duration.setDateNumericValue(current.calendar_duration.dateNumericValue()+(gs.dateDiff(current.opened_at.getDisplayValue(),current.closed-at.getDisplayValue(),true)*1000));
//calendar duration is set getting the current calendar duration and adding it to the difference between opened_at (set in previous script above) and closed_at value which is set above. We add 1000 becuase we are converting seconds to miliseconds
}
Hope this helps