locked
actual duration doesnt work RRS feed

  • Question

  • hi

    i am using actualstart and actualend field in a form, i want to calculate actual duration of these two date, so i use actualduration filed, but it doesnt work automatically according to actualstart and actualend field like schedualed duration??!!

    Wednesday, January 16, 2013 8:50 AM

Answers

  • Hi,
       I just a gave try on my app, it looks like actual duration is not getting caluculated based on the difference between actual end and actual start. So, you can keep JScript to do that on the "onchange" of "actual start" and "actual end" fields. You can use following JScript to do that:

    fuction CalActualDuration()
    {
    var actualstart = Xrm.Page.getAttribute('actualstart').getValue();
    var actualend = Xrm.Page.getAttribute('actualend').getValue();
    var diff = Math.abs(actualend - actualstart);
    var minutes = Math.floor((diff/1000)/60);
    Xrm.Page.getAttribute('actualdurationminutes').setValue(minutes);
    }


    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"

    • Proposed as answer by Vikranth Pandiri Wednesday, January 16, 2013 9:29 AM
    • Marked as answer by samira_a Thursday, January 17, 2013 7:52 AM
    Wednesday, January 16, 2013 9:29 AM
  • This article has a good "How to" on creating a web resource to hold your javascript function (which is what you need to do), then calling the function from inside this "Library":
    http://crmconsultancy.wordpress.com/2010/10/19/form-scripting-in-crm-2011/

    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    • Marked as answer by samira_a Thursday, January 17, 2013 7:52 AM
    Wednesday, January 16, 2013 3:54 PM

All replies

  • Hi,
       I just a gave try on my app, it looks like actual duration is not getting caluculated based on the difference between actual end and actual start. So, you can keep JScript to do that on the "onchange" of "actual start" and "actual end" fields. You can use following JScript to do that:

    fuction CalActualDuration()
    {
    var actualstart = Xrm.Page.getAttribute('actualstart').getValue();
    var actualend = Xrm.Page.getAttribute('actualend').getValue();
    var diff = Math.abs(actualend - actualstart);
    var minutes = Math.floor((diff/1000)/60);
    Xrm.Page.getAttribute('actualdurationminutes').setValue(minutes);
    }


    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"

    • Proposed as answer by Vikranth Pandiri Wednesday, January 16, 2013 9:29 AM
    • Marked as answer by samira_a Thursday, January 17, 2013 7:52 AM
    Wednesday, January 16, 2013 9:29 AM
  • hi

    i am newbie in CRM, where should i add this code?? i select the actualstart field in my form and click on change properties, in event tab i saw onchange event, but when i clicked on "add"  i got some error about adding library, then i added one library , then i click "add" again for onchange event but , doesnt know where i should add this code??


    • Edited by samira_a Wednesday, January 16, 2013 1:23 PM
    Wednesday, January 16, 2013 1:20 PM
  • This article has a good "How to" on creating a web resource to hold your javascript function (which is what you need to do), then calling the function from inside this "Library":
    http://crmconsultancy.wordpress.com/2010/10/19/form-scripting-in-crm-2011/

    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    • Marked as answer by samira_a Thursday, January 17, 2013 7:52 AM
    Wednesday, January 16, 2013 3:54 PM
  • it workksss.thanks  alot for youe help
    Thursday, January 17, 2013 7:52 AM