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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2013 - JScript calculation - dates (diff days, hours)

(0) ShareShare
ReportReport
Posted on by

Hi all, 

Have something for which I need advice or simple JavaScript code/functions.  I am currently using CRM 2013 On Premise.  

The scenario is this.  I am developing a mobile crisis form/functionality that will track, based on an Encounter Type, the time (diff days/hours) it took from when the Encounter (either Face to Face or Phone Call) ended - until the time the Encounter was Closed and the time captured.  Since I am on 2013, I cannot use calculated fields here and need to use JScript at this time for function - SetDiffDays() {.  

Calculation 1 - if 'Encounter Type' = Face to Face - Round Trip Travel or Face to Face - One way travel, and the 'Encounter Status' = Closed, and 'Encounter Closure' (Date/Time field type) Contains Data, calculate the diff (days and hours) between the 'End Face to Face' field and the 'Encounter Closure' Field, and place this in the 'Encounter Total Time' field.


Calculation 2 - if 'Encounter Type' = Telephone Only - En Route, and the 'Encounter Status' = Closed, and 'Encounter Closure' (Date/Time field type) Contains Data, calculate the diff (days and hours) between the 'DT Call End' field and the 'Encounter Closure' Field, and place this in the 'Encounter Total Time' field.

These changes need to occur when the form is Saved, or when one of the above fields is changed.  

I attached some screenshots to help.

I know this is a big ask - does anyone have code they could send me that would solve this?  Code that not only I would use as the web resource, but that I could place on the form properties for OnChange Event?

Encounter-Type.PNG

EndFacetoFace.PNG

DTEndCall.PNG

EncounterTotalTime.PNG

*This post is locked for comments

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans