Search code examples
c#sql-serverlightswitch-2013

Lightswitch 2013 set date to now


pretty simple question again, my question is how do I call the below method in lightswitch, because currently it is never used and therefore leaving the CreatedDate column blank on my server side.

namespace LightSwitchApplication
{
public partial class Table_Name
{
    partial void Table_Name_Created()
    {
       CreatedDate= DateTime.Now;
    }

}

the above Syntax would usually work and I know it will work if it was to be called.... I've put a break point in and it is never interrupted so do I need to do something extra to call it?

currently the table resides on SqlServer and the use of the below SQL Statements does nothing:

alter table Table_Name add CreatedDate datetime not null DEFUALT GETDATE()
alter table Table_Name add CreatedDate datetime DEFAULT GETDATE()

I can set up a procedure like this but that is a procedure that should not be required:

create procedure CreatedDateProcedure as
update Table_Name set CreatedDate = GETDATE() where CreatedDate =
(select top 1 CreatedDate from Table_Name order by desc)

Thanks for any help


Solution

  • Solved:

    myapp.AddEditBooks.created = function (screen) {
    
    screen.Bookshelf.Bookloandate= Date.now();
    };