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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

how to change/override a date that is "calculated-read only" by using a button

Avatar

Level 5

Good day,

I have a date field on my form that is calculated-read only.  The current date is entered each time the form is opened.  I would like to have a button that will allow a specific user to be able to change the date when needed.  Is there a way to do this?

 

1 Accepted Solution

Avatar

Correct answer by
Level 6

Remove the calculated property from the field. Make it readOnly to set the value and on the button click make the access to open.

View solution in original post

4 Replies

Avatar

Level 6

You need to change the "yourFieldName.access" property to desired value in button click event.

 

yourFieldName.access="open";

Avatar

Level 5

Good day,

I did not reply that the answer was correct.  Actually, it's not working.  After entering the information in the click event, I get the following pop-up - "The value you entered for todaydate cannot override its calculated value".  When I hit "ok", the date reverts back to the today's date.

Avatar

Correct answer by
Level 6

Remove the calculated property from the field. Make it readOnly to set the value and on the button click make the access to open.

Avatar

Level 5

Good day,

This is still not working for me.  I must be doing something wrong.  When I remove the calculated property and make it "readOnly" the date does not appear when I open the form.  The date block is blank and therefore the button does not work either.  Do I need to enter a script in the date field?  I need the current date to appear in the date block when the form is opened and I would like to have a button that can override/change the date if needed.

 

Avatar

Level 6

Yes, on initialize event you need to set the date 

 

if(dateField.rawValue == null || dateField.rawValue == ""){

//set dateField value

}

Avatar

Level 5

ok. i got it to work by changing the value to  

"Read only" in the field and adding

$.rawValue = Num2Date(Date(), "YYYY-MM-DD") in the initializing event

and in the click event of the button I entered

oTargetField = this.resolveNode("header.datesub.todaydate");
oTargetField.access = "open";

 

How do I require a password on the click button so that only a user can do this?

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now