cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Two Dates in Adobe Forms in JavaScript

01-12-2024 8:08 AM
disaljayaweera Newcomer
530 views 0 comments
0 Likes
SAP Managed Tags
Subscribe

Hi Experts.


I need to compare two dates in an Adobe Form based on the value of a Date Field within the form.

Within the same Subform there is a Date Field (AEDAT) and a Text Field (COMPNAME).

If the date displayed in the date field is after 12th December 2023, the text in the Text Field should be displayed without any changes (as passed from the interface).

If the date displayed in the date field is on or before 12th December 2023, a section of the text displayed in the Text Field should be removed accordingly.

Current JavaScript code is given below (scripted in the initialization of the Subform).

const lv_date_1 = new Date("2023-12-31");
const lv_date_2 = new Date(AEDAT.rawValue);
if(lv_date_2 <= lv_date_1){
COMP_NAME.rawValue = COMP_NAME.rawValue.replace(/TestText/g, "");
COMP_NAME.rawValue = COMP_NAME.rawValue.trim();
}

The IF condition does not work since the text is modified regardless of whether the date is before or after 12th December 2023.

Can anyone help me solve my problem please.

Thanks in advance.

0 Likes

Accepted Solutions (0)

Answers (0)