- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2014 08:36 AM
Hi,
We are looking to create a report for Change Management which will show the time between a change moving to 'Review' state and the 'Planned Start' date of the change record.
We would like the time to be calculated for every change, so the information can then be exported and we can work out an average. However if there is a way to obtain the time between Review and Planned Start for each record and an average then that would be great.
Please let me know if further information is required.
Thanks in anticipation,
Emma
Solved! Go to Solution.
- Labels:
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 07:36 AM
Hi Emma,
Lets keep things simple and get this done
Business rule script
var planned_start_date = gs.now()
var daysDuration = gs.dateDiff(current.start_date,gs.now());
current.u_lead_time =daysDuration;
/*I have tried this on demo and its works just fine(provided you planned start date has a value, you can add checks).*/
And Lead Time field is 'duration'
You can see the same if you log on to
https://demochannel.service-now.com
Create any change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 02:08 AM
That would be great if you could help with the script please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 02:07 AM
Hi Anurag,
Thank you for your reply.
Would a script be required to achieve this type of metric?
I have very little knowledge when it comes to scripting so was looking for some advise on how this could be achieved?
Kind regards,
Emma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 02:24 AM
just confirming the requirement here. You want to calculate the difference between the planned start date and the actual time when the ticket moved to review.
Write a Business Rule
When : Before
Table: change Request
Condition: current.state.changesTo('Review') //here you will have to provide the numerical value of the state
Script
var getUserDateFormat = gs.getDateFormat();
var dateFormatHelper = new DateFormatHelper();
var currentDate = dateFormatHelper.getDateInUserFormat(gs.now() , getUserDateFormat); //this is the date when ticket moved to review
var planned_start_date = dateFormatHelper.getDateInUserFormat(current.start_date , getUserDateFormat); //planned start date in the specific format
var daysDuration = gs.dateDiff(planned_start_date ,currentDate);
current.<your field where you want to save duration > =daysDuration ;
/* Duration gets calculated in format - days hours mins seconds(25 10:55:52),if you have to extract the day part from it.
dateDifference = daysDuration.split(' ');
*/
This should work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 03:25 AM
Thank you, I have created the business rule and added a new field to the change_request table named u_lead_time. The field is a string field but I have also tried with Integer and this doesn't work either.
Unfortunately, the 'lead time' field is not populating with the output of the script. Please could you advise if you see any errors or what could be causing this problem?
Please see below condition and script:
Condition: current.state.changesTo('-5')
Script:
var getUserDateFormat = gs.getDateFormat();
var dateFormatHelper = new DateFormatHelper();
var currentDate = dateFormatHelper.getDateInUserFormat(gs.now() , getUserDateFormat); //this is the date when ticket moved to review
var planned_start_date = dateFormatHelper.getDateInUserFormat(current.start_date, getUserDateFormat); //planned start date in the specific format
var daysDuration = gs.dateDiff(planned_start_date,currentDate);
current.u_lead_time =daysDuration ;
/* Duration gets calculated in format - days hours mins seconds(25 10:55:52),if you have to extract the day part from it.
dateDifference = daysDuration.split(' ');
*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 03:58 AM
Make the Field type duration (glide_duration)
If that dosent work properly then
modify this line of the code
current.u_lead_time =daysDuration.toString() ;