


Hello guys, how are you?
So, I need to get the date the user fills a form on my site as an user generated content along with the form fields everytime a user fills this form. I'm using the store content action on my form.
To do this, I've copied the foundation hidden value field and added some custom code:
Date today = new Date(); int dd = today.getDate(); int mm = today.getMonth()+1; int yyyy = today.getYear(); String strDd = ""; String strMm = ""; String strYyyy = ""; if(dd<10) { strDd='0'+ Integer.toString(dd); } if(mm<10) { strMm='0'+ Integer.toString(mm); } String strToday = Integer.toString(dd) +'/'+ Integer.toString(mm) +'/'+ Integer.toString(yyyy); Node node = resource.adaptTo(Node.class); node.setProperty("defaultValue", strToday); node.setProperty("name", "Data"); node.getSession().save();
Doing this I do get a date on the defaultValue of my hidden value component content node and in the user generated data, but always the same date (the date I've created and dropped the component in the form). How do I do to get a new date everyday? Everytime a user fills the form, the component should get the current date. Is this possible changing this code or in some other way?
Edit: Working with AEM 6.0, SP3 (I am, not the component.)
Thanks very much.
Matheus Barreto.
Views
Replies
Sign in to like this content
Total Likes
You can change the code in a form script to get the current date using JavaScript.
Views
Replies
Sign in to like this content
Total Likes
Views
Replies
Sign in to like this content
Total Likes
Hi
Moving this thread to AEM "Forms" topic so to have better contextual experts have a look at this.
~kautuk
Views
Replies
Sign in to like this content
Total Likes
Matheus, looking at the above code, can you confirm whether or not you're trying to populate an Adaptive Form or is this a Site form?
Views
Replies
Sign in to like this content
Total Likes
Hi, how are you? Site form, the native form component, not adaptative one. Any tip or trick? 🙂
Thanks!
Views
Replies
Sign in to like this content
Total Likes
Still waiting for some help. Is there any other channel where I can try to find help regarding this topic?
Views
Replies
Sign in to like this content
Total Likes