Expand my Community achievements bar.

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

javascript weekday format

Avatar

Former Community Member

I have the following javascript in a form I am creating in LiveCycle.  The first item, setting the ReportDate works fine.  The second item does not.  It puts eeee in the field, and not the weekday's name.  I even tried using "eee" and "EEEE" and "EEE" to only get the "e" characters placed in the field as they are listed. What might I have wrong?

form1.#pageSet[0].Page1.SaveAsButton::click - (JavaScript, client)

// Place the current Date and Day in the appropriate fields on the form

Page1Header.ReportDate =  util.printd("mm/dd/yyyy", new Date());

Page1Header.ReportDay = util.printd("eeee", new Date());

Regards,

Karl

1 Accepted Solution

Avatar

Correct answer by
Level 10

You are mixing JavaScript with FormCalc keywords.

EEEE- is a FormCalc keyword to get the Weekday.

In java Script, you can get the Weekdays in numbers.

So you have to write code to get the matching spelled out name for the weekday.

Try something like this..

var d=new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";

xfa.host.messageBox("Today is " + weekday[d.getDay()]);

Page1Header.ReportDay.rawValue = weekday[d.getDay()];

Thanks

Srini

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You are mixing JavaScript with FormCalc keywords.

EEEE- is a FormCalc keyword to get the Weekday.

In java Script, you can get the Weekdays in numbers.

So you have to write code to get the matching spelled out name for the weekday.

Try something like this..

var d=new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";

xfa.host.messageBox("Today is " + weekday[d.getDay()]);

Page1Header.ReportDay.rawValue = weekday[d.getDay()];

Thanks

Srini