You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Validate address start date to not be in the past - validation not firing

Summary:

We want to prevent employees from entering a new address with a past date.

Content (please ensure you mask any confidential information):

Below is what I have and it is not working.

/* eslint-disable dot-notation */

define([], () => {  'use strict';
  /**  @param {object} context   * @return {boolean}   */ 

function runCondition(context) {   

const { $componentContext, $fields, $modules, $user } = context;     

// Get current date and set to midnight   

const currentDate = new Date();

currentDate.setHours(0, 0, 0, 0);         // Get and convert the start date   

const effectiveStartDateValue = $fields.personAddress.EffectiveStartDate.$value();      

const parts = effectiveStartDateValue.split('-');   

const effectiveStartDate = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2]));
// Compare the dates and return the result directly

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!