Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

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

$
0
0

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?


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images