Calculate difference between Actual Start & Actual End in Minutes

Task: Calculate difference between Actual Start Date & Actual End Date in minutes and Setvalue in Duration field onSave of Phone Call entity

Solution: Follow the below steps,

Step 1: Create Javascript Webresource “new_phoneCallJscript”. Copy and paste the below code in Javascript Webresource,

Step 2: Call the function calculateDurationinMinutes onSave of phonecall entity

function calculateDurationinMinutes() {
var actualStartObj = Xrm.Page.getAttribute("actualstart");
var actualEndObj = Xrm.Page.getAttribute("actualend");
var durationinMinutesObj = Xrm.Page.getAttribute("actualdurationminutes");
    if (actualStartObj != null && actualEndObj != null && durationinMinutesObj != null) {
       var actualStart = actualStartObj.getValue();
       var actualEnd = actualEndObj.getValue();
         if (actualStart != null && actualEnd != null) {
            var dateDifference = Math.abs(actualEnd - actualStart);
            var durationInMinutes = Math.floor((dateDifference / 1000) / 60);

Step 3: Save and Publish the Phone Call Activity. Open any Phone Call record and Select the value Actual Start and Actual End and click on Save to see the result in Duration field.

Please provide your valuable feedback on this article.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.