Expand my Community achievements bar.

Comparing Date Fields to change the visibility of a subform

Avatar

Level 1

I have been trying to figure out how to compare date fields in LiveCycle Designer ES2.

I have two date fields: "First Draft Due" and "Final Due"

On exit from Final Due I want to automatically compare the fields. If they are less than 48 hours apart, I want to make the word "Rush" appear at the top of the form.

I have a hidden SubForm "RUSH" at the top of the form.

Any help would be greatly appreciated.

Thanks.

4 Replies

Avatar

Level 10

Hi,

assuming you have 2 date fields (DateField1 and DateField2) you can use the following FormCalc script in DateField2 exit event.


if (not $.isNull and not DateField1.isNull) then


  var dateFmt = "MM/DD/YYYY"


  var firstDate = Date2Num(DateField1.formattedValue, dateFmt)


  var finalDate = Date2Num($.formattedValue, dateFmt)


  if (Abs(finalDate - firstDate) le 2) then


  RUSH.presence = "visible"


  else


  RUSH.presence = "hidden"


  endif


endif


Avatar

Level 1

Radzmar:

Thank you for the script. However, I am not able to get it to work, and I am not sure why.

This is the complete script that I put in the exit event for DateDue:

if (not $.isNull and not DateSubmitted.isNull) then

    var dateFmt = "MM/DD/YYYY"

    var firstDate = Date2Num(DateSubmitted.formattedValue,dateFmt)

    var finalDate = Date2Num($.formattedValue, dateFmt)

        if (Abs(finalDate - firstDate) le 2) then

        RUSH.presence = "visible"

        else

        RUSH.presence = "hidden"

    endif

endif


At first I thought it might be missing some further detail for the fields since they are inside a subform, so I added "GRAPHICREQFORM.GENERALINFO." in front of "DateSubmitted" and "RUSH"


That did not work.


Then I tried using "<=" instead of "le", and that did not work, either.


I am sorry, but my knowledge of javascript is limited and I am not sure if I am overlooking something obvious.


Any further help you can provide would be greatly appreciated.


Thank you.


Avatar

Level 10

The script is NOT JavaScript but FormCalc. Make sure to have selected the correct language.

Avatar

Level 1

Well, that explains a lot, doesn't it?

I made the change, and it is working fine.

Thanks again.

Bob