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

Javascript track when field loses focus

$
0
0

We have a business need to check if users are filling out time entry details in current time or if they are going back and updating after the time entry should be closed.  On our time entry entity we have 4 fields actual start, actual end, time entry details and real time (yes/no).  If focus is lost outside of the start and end time meaning if the user edits time entry details between those times (or if end time is null) then the time entry is considered real time if user edits the time entry details outside of the actual start and actual end times the time entry is considered not real time. I am pretty new to javascript so any help is very much appreciated!!  Also not entirely sure if this should solely be on the field as an OnChange event or on the form as an OnLoad event or both.  Thanks again!

I have this java script but it doesnt appear to be tracking the blur event correctly:

functionRealTime(executionContext) {
  varformContext = executionContext.getFormContext();
  varactualStart = functionmonitorFieldFocus() {
  varactualStart = formContext.getAttribute("e3_actualstart").getValue();
  varactualEnd = formContext.getAttribute("e3_actualend").getValue();
  varrealTime = formContext.getAttribute("e3_realtime");

  varstartTime = newDate(actualStart);
  varendTime = newDate(actualEnd);

  formContext.getControl("e3_timeentrydetails").addOnBlur(function () {
    varfieldValue = formContext.getAttribute("e3_timeentrydetails").getValue();
    varfieldTime = newDate(fieldValue);

    if (fieldTime< startTime || fieldTime> endTime) {
      realTime.setValue(false);
    }
  })}}



Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>