web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Check the code for error free

(0) ShareShare
ReportReport
Posted on by 958

function time()

{

var stdate = Xrm.Page.getAttribute("new_starttime").getValue();

var endate = Xrm.Page.getAttribute("new_finishtime").getValue();

if(stdate == null && endate == null)

{ alert(“Please enter the Start Time / Finish Time…”);

return false;

}

else if(stdate==null)

{ alert(“Please enter the Start Time !”);

return false;

}

else if(endate==null)

{ alert(“Please enter the Finish Time !”);

return false;

}

var st=stdate.getTime();

var ed=endate.getTime();

var sdiff=(ed-st);

var h=(sdiff/60/1000);

var p=parseInt(h);

var tm=p.toString();

Xrm.Page.getAttribute("new_timespent").setValue(tm);

}

Above code is for making two calculated fields Starting Date/time(when record is created) and Ending Date/time(current time of system). Then we make third different field which is Time Spent which is also calculated field. So, check the code for error free and if there are another way to make the calculated field send me link.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at

    Hi Shakti,

    What version of CRM do you have , did you try out of the box calculated field if available?

    technet.microsoft.com/.../dn832103.aspx

    otherwise , code is okay. run it & post error if you get any/.

  • Shakti Singh Rajput Profile Picture
    958 on at

    Thank you Rawish

    And I am using Dyanmics 365 CRM Online(Trial version)

  • Verified answer
    Community Member Profile Picture
    on at

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans