Expand my Community achievements bar.

LiveCycle Form - Calculate Ordinal Date and Append the Answer to a User Provided Value

Avatar

Level 1

LiveCycle - Ordinal Date Question (15 MAR 12).JPG

I have scoured the web and while I have found numerous references, I'm not sure how to apply them to my specific situtation.

While techincally adept I do possess an abundant lack of coding experience, Point me in the right direction or if there is a coding solution, it would be best if I could cut and paste into the XML Source area. 

Thank you, I appreciate any assistance.

- Bill

14 Replies

Avatar

Level 5

Is it just the number of days from FYQ1 you are looking for no matter what the year? To do something like this, add the following to the change event of the date field

if ( xfa.event.newText != "" )

{

    // match DD/MM/YYYY

    var parts = xfa.event.newText.match(/(\d+)/g);

    var day = parts[0];

    var month = parts[1];

    var year = parts[2];

   

    var currDate = new Date( year, month-1, day );

    if ( month < 10 )

        year--;

    var fyDate = new Date( year, 9, 1 );

    var msDay = 1000 * 60 * 60 * 24;

    var diff = ((currDate - fyDate) / msDay);

    // number of days - which should be concatenated with some user value

    TextField3.rawValue = Math.round(diff);

}

make sure the edit pattern of the date field matches the code - i.e. DD/MM/YYYY, otherwise you would have to switch it around

Avatar

Level 1

Thank you for your time, I know we're close.....

I'm still unclear on a couple of points:

1. Does your script rewrite the original "DD/MM/YYYY" field or is the final solution output to your "TextField3" ?

In my form the reference date field is "ORDER_DATE" and the date field I inserted for the calculated FY Julian/Ordinal date is named "FY_ORDINAL_DATE"

2. Your Remark "// number of days - which should be concatenated with some user value"   I believe this would be a reference to the following:

In my form I have a text field "GPC_NUMBER" which is a 19 digit sequence, patterned "text{9999-9999-9999-9999-999}" where the last three (3) digits "...-999}" needs to be the the value from "FY_ORDINAL_DATE

Can you provide me with any additional insight ?

Avatar

Level 5

1. The script is output to TextField3 only, so no it doesnt change any existing values being used as inputs. If FY_ORDINAL_DATE is to contain the number of days then switch that in for TextField3.

2. I was presuming you wanted to concatenate some user entered data with the ordinal date to derive the gpc_number. Or is it more of a validation as in a digit check? You can do further script at this location to handle the gpc_number or you can handle that in some other event (i.e. calculate/exit, etc) since you now have the ordinal date

Avatar

Level 1

Regarding #2

How do I add the FY_ORDINAL_DATE to the end of GPC_NUMBER?

Avatar

Level 5

It would be something like GPC_NUMBER.rawValue = first_part.concat(FY_ORDINAL_DATE.rawValue);

where the first_part is the source field or calculation of the beginning of the number. Probably check if first_part is null first before doing the concatenation.

Avatar

Level 1

Hi,

I have not progressed even to this point yet.  I'm hoping all of you can help:

I need to have a solution so that when a user selects a date from the pop-up calendar, a reference box automatically contains the equivelant Julian date.  The Julian date is used as the part of the record number for the document so it is important.

Thanks in Advance,

V

Avatar

Level 6

V,

Julian dates can be confusing.  First, do you mean Julian Date or Julian Day Number?  Julian Date is a fractional number, Julian Day Number is a whole number. For a record number I'm not sure if you want decimals.  Also, you need to decide if you want to use the Julian or Gregorian calendar as your base.  Finally, I'm assuming that you only care about recent dates, which simplifies things a bit.

Avatar

Level 1

Hi Kevin,

Thanks for the response.

I only need a 3-digit Julian day number (for example day 032 is February 1st) -based on the gregorian calendar.  I am hoping that when someone selects a date from date/time field pop-out, that another box is populated by the 3-digit Julian Day.

And yes, I only care about recent dates, as the year is expressed elsewhere on the form anyway.

Thanks in Advance,

V

Avatar

Level 1

Hi,

I have problen in my PDF form "if statments and FV, NPV"? on Calculations.

I can share excel file and PDF Filllable form.

Thanks,

Sheraz

Avatar

Level 1

Hi Kevin,

Thanks for the response.

I only need a 3-digit Julian day number (for example day 032 is February 1st) -based on the gregorian calendar.  I am hoping that when someone selects a date from date/time field pop-out, that another box is populated by the 3-digit Julian Day.

And yes, I only care about recent dates, as the year is expressed elsewhere on the form anyway.

Thanks in Advance,

V

Avatar

Level 1

dohanlon... any chance you could post an example of your final script that worked?  I am trying to put a 3-digit date code as a part of a registration number and am a little hung up.

Thanks in advance!

Avatar

Level 3

The code above does not seem to work. I have tried to use it on a form, and while it does return a number, it is not the correct number. When I enter 1/1/13, it should return 001 or at least 1--Currently it is returning 92, which is not correct at all.