Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

References in Javascript

Level 5
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


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-")

{"You Have Entered An Invalid RA Prefix");


if (RA2 != b)

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


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

{"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  )

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



0 Replies