Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

References in Javascript

Avatar

Level 5

I wrote this javascript to check a form field. The form field contains a tracking number, i.e. RA-12-53719. The field name is RA and it always contains: "RA-", the current year in two digits, and a then a 5 digit number. The code works in a javascript test online, but not inside of LiveCycle. I am confused on what the correct reference is in LiveCycle . If a field is named "RA" do I always refer to it as the hierarchy: form1.P1[0].INC[0].RA[0]? I think this may be the problem I am having. Any ideas?

I figured out the answer with some help from others. The correct answer is here and probably can be condensed further:

//Resolve Tracking Number into components of : RA- YY XXXXX

xfa.resolveNode("RA");

var RAO=RA.rawValue;

var RA1 = RAO.substr(0,3);   

var RA2 = RAO.substr(3,2);

var RA3 = RAO.substr(6);   

var RA3P = parseInt(RA3);

var RA3L = RA3.length;

var e = parseInt(RA3L);

//Produce current year in a two digit string format

var nd = new Date();

var a = nd.getFullYear();

var b = a.toString().slice(2);

//Comparison Statements

if (RA1 != "RA-")

{ xfa.host.messageBox("You Have Entered An Invalid RA Prefix");

}

if (RA2 != b)

{ xfa.host.messageBox("You May Have Entered An Invalid RA Year. The Current Year " + f + " Should be reflected in the RA Number");

}

if (RA3  == "XXXXX" || isNaN(RA3)  )

{ xfa.host.messageBox("You Have Not Entered a Valid RA Number Where The XXXXXs Are. Please Enter the Appropriate Number Where the XXXXXs Are.");

}

if ( RA3P > 99999 || e < 5 || e > 5  )

{ xfa.host.messageBox("You Have Entered an Invalid RA Number. RA Numbers Are 5 Digits Long.");

}

//Success!

0 Replies