Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Multilayered date issue Populate the current date. User can edit date. Compare to 2nd user date.

Avatar

Level 2

This is a multi layered date question.

The requirement is to populate a date field with a current date which may or may not be appropriate.

The user can edit the date field as appropriate. The preferred format is MM/DD/YY.

A second date is entered and compared to the first date and errors if earlier than the first date. If either is null then let them be.

The user completes all fields then signs the form which starts an email sequence to automatically mail the PDF form and properly name the subject and body line in Outlook.

Here is what I have so far. Most of this I pulled from the forums and.

The auto populating date field works ok but may be breaking the comparison between the 2nd date.

if (vDate1.rawValue == null){

var msNow = (new Date()).getTime();

var d1 = new Date(msNow);

vDate1.rawValue = util.printd("mm/dd/yy", d1);

}

else {

vDate1.rawValue = rawValue;

}

The date comparison works ok but I have some issues making sure both date entries are validated correctly. I want them to use MM/DD/YY

if(vDate2.rawValue <> null and vDate1.rawValue <> null)then

if(vDate2.rawValue < vDate1.rawValue) then

xfa.host.messageBox("Please check your meter calibration due date.  It cannot be before

the survey date!", "Date Checker", 3)

$.rawValue = ""

// to set focus to the End Date field

xfa.host.setFocus(this.somExpression)

endif

endif

I am using the signature event to call the click which works ok

topmostSubform.Page3.SignatureField1::click - (JavaScript, client)

Button1.execEvent("click");

The click forces the user to save the pdf and attaches to the email and fills in the subject line. I have been struggling to get that vDate1.rawvalue to appear as MM/DD/YY in the subject line. When it does work the date comparisons break.

Button2.event__click.submit.target = "company@company.com?subjectmailto:yourcompany@company.com?subject@yourcompany.com?subject=" + CODE_NO.rawValue + " " + " company" + " " + MODEL_NO.rawValue + " " + WORKORDER.rawValue + " " + SSERIAL.rawValue + " " + vDate1.rawValue + " " + RLS_REASON.rawValue;
Button2.execEvent("click");

I had to add several invisible variable boxes because I apparently do not know how to initialize properly.

It seems I can either :

  • Auto populate the current date but not run the comparison.
  • Have the appropriate date format appear on the email subject but not drop in the automated current date.
  • Have the correct format on everything "MM/DD/YY" but no calculations run properly.

I am hoping someone can help me out here.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Bruce,

Well when I try to format the date it breaks the date comparison but the date looks nice (MM/DD/YY).

I am not doing something correctly. If I could get a default current date that can be user entered optionally and be checked against the second date that would be optimal.

Each piece works ok by itself. When all the pieces are added,  there are problems.

If someone wants to take a look at it let me know an email and I can fire it over.

D

View solution in original post

2 Replies

Avatar

Level 10

Hi,

You could try using the vDate1.formattedValue to get the date is in format specified by the display pattern.  If you haven't updated the data pattern the date will be in yyyy-mm-dd format, so I am guessing you have updated it?  If the data pattern and the display pattern are different the the formattedValue will equal the rawValue when the date is invalid.  So if it is valid the date gets formatted as specified in the data pattern, if not the the value gets copied across as is.

Hope that helps

Bruce

Avatar

Correct answer by
Level 2

Bruce,

Well when I try to format the date it breaks the date comparison but the date looks nice (MM/DD/YY).

I am not doing something correctly. If I could get a default current date that can be user entered optionally and be checked against the second date that would be optimal.

Each piece works ok by itself. When all the pieces are added,  there are problems.

If someone wants to take a look at it let me know an email and I can fire it over.

D