- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 05:46 AM
Hi
I have two Date and Time type field Actual Start Date and Actual End Date and I have another field duration type field name as Duration.
I have to capture duration in this field. How can I do that ?
Thanks,
Sourabh
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 09:01 AM
Hi sourabh,
Please create fields as below.
Actual Start Date
field name: startdate
Type: Date/time
Actual End Date
field name: enddate
Type: Date/time
Duration Type
field name: duration
Type: Duration
Create a business rule with the below code on which ever needed. Like on update or insert.
getTimeDiff();
function getTimeDiff(){
var startDate = current.u_startdate.getGlideObject();
var endDate = current.u_enddate.getGlideObject();
current.u_duration = gs.dateDiff(startDate.getDisplayValueInternal(),endDate.getDisplayValueInternal(),false);
Kindly mark as correct if this helps you.
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 06:09 AM
Hi,
You can refer the below links for implementing your solution:
Calculate Duration Given a Schedule - ServiceNow Wiki
Setting the Duration Field Value - ServiceNow Wiki
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 06:58 AM
I wrote a post about using duration with a schedule here if you wanna take a look: How to close ticket after 3 business days
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2017 09:01 AM
Hi sourabh,
Please create fields as below.
Actual Start Date
field name: startdate
Type: Date/time
Actual End Date
field name: enddate
Type: Date/time
Duration Type
field name: duration
Type: Duration
Create a business rule with the below code on which ever needed. Like on update or insert.
getTimeDiff();
function getTimeDiff(){
var startDate = current.u_startdate.getGlideObject();
var endDate = current.u_enddate.getGlideObject();
current.u_duration = gs.dateDiff(startDate.getDisplayValueInternal(),endDate.getDisplayValueInternal(),false);
Kindly mark as correct if this helps you.
Regards
Param