Skip to main content

Notifications

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

  • Verified answer
    Community Member Profile Picture
    on at
  • Shakti Singh Rajput Profile Picture
    958 on at
    RE: Check the code for error free

    Thank you Rawish

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

  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Check the code for error free

    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/.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans