Can't Set DateTime Entity Property Default with Usual Code in HTML Preview 2
-
Sunday, November 18, 2012 10:26 PM
Hi,
I added a SurveyDate property to the Survey entity of the Contoso Survey app, clicked Write Code, selected Survey_Created and added the usual line of code to the stub.
Uploaded and deployed the project as a SharePoint app, ran it from the Developer Site and didn't get the expected current date and time when adding a new survey.
Any idea what the problem is?
(See the image with manually entered values by scrolling down in my LightSwitch HTML Client Preview 2: OakLeaf Contoso Survey Application Demo on Office 365 SharePoint Site post.)
Cheers,
partial void Survey_Created()
{
this.SurveyDate = DateTime.Now;
}
Microsoft Access 2010 In Depth (QUE Publishing)
OakLeaf Blog
Access 2010 Blog
Amazon Author Blog
- Edited by Roger JenningsMVP Sunday, November 18, 2012 10:34 PM
- Edited by Roger JenningsMVP Sunday, November 18, 2012 10:35 PM
All Replies
-
Monday, November 19, 2012 6:58 AMModerator
In the case for an HTML client, the Survey_Created method in your code will not be invoked unless the entity was created by the server, not on the client, hence why you do not see the date being initialized client-side correctly. Please see New LightSwitch HTML Client APIs for an example on how to write JavaScript that will initialize an entity property during entity creation.Justin Anderson, LightSwitch Development Team
- Marked As Answer by Roger JenningsMVP Monday, November 19, 2012 3:32 PM
-
Monday, November 19, 2012 3:35 PM
Hi, Justin,
Thanks. That worked like a champ.
Guess I should have read Stephen Provine's API post.
Maybe Preview 2 will convince me to finally learn JavaScript programming.
Cheers,
--rj
Microsoft Access 2010 In Depth (QUE Publishing)
OakLeaf Blog
Access 2010 Blog
Amazon Author Blog

