Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Pass value to task duration

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

wondering is someone could give me advice, we are tracking engineer time by using the task activity view. we log start date and time, finish data and time and duration. At the moment the way i have it is "finish time" date/time is calculated field so i use the formula AddHours((actualdurationminutes / 60), actualstart)

Therefore i enter the start time, duration and its populates the finish time. Just wondering is there anyway of adding start and finish time to get the duration time populated. The duration time in task activity is a whole number. Think duration field in task activity this relates to case resolution field so dont think i can create new duration field.

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Pass value to task duration

    You can do this with JavaScript or Business Rules.

    Although, I am not sure if you will end up in an endless loop, but worth a try.

    Basically in JavaScript:

    var startDate = Xrm.Page.getAttribute("startdate").getValue();

    var endDate = Xrm.Page.getAttribute("enddate").getValue();

    var day = 1000 * 60 * 60 * 24;

    var duration = ((end - start) / day) + 1;

    Xrm.Page.getAttribute("duration").setValue(duration);

    You can also control your end date if you want based on duration:

    var startdate =  Xrm.Page.getAttribute("startdate").getValue();

    var duration = Xrm.Page.getAttribute("duration").getValue();

    var enddate = new Date();

    enddate .setTime(startdate .getTime() +  (duration * 24 * 60 * 60 * 1000));

    Xrm.Page.getAttribute("enddate").setValue(enddate);

    Hope this helps.

  • AJAnsari Profile Picture
    AJAnsari 5,754 on at
    RE: Pass value to task duration

    It looks like you've reached the wrong forum. Please inquire in the Dynamics 365 Enterprise Edition or the Dynamics CRM forum.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans