locked
Calling stored procedure from lightswitch HTML Client vs 2013 --answered!! RRS feed

  • Question

  • Hi,

    I'm trying out my hand with lightswitch 2013 HTML Client .I'm trying to call SP from Lightswitch button click.I was following the example from below link

    http://msdn.microsoft.com/en-us/library/jj635144.aspx

    until i got stuck at step where short cut menu for a button contains edit execute code.On click of this command my application directs me to a JS function as "_execute= function(screen) (client side code)

    but the tutorial shows steps for c# code(server side).

    did i missed something?


    • Edited by PriyaMat Thursday, May 8, 2014 7:00 PM
    Thursday, May 8, 2014 3:46 PM

Answers

  • Hi,

    That example is using a Silverlight client (desktop/web rich client).

    Some equivalent javascript code would look like this:

    myapp.EmployeesListDetails.UpdateEmployeeInfo_execute = function (screen) {
    
        var dws = screen.details.dataWorkspace;
        var employee = screen.Employees.selectedItem;
    
        var operation =
            dws.ApplicationData.UpdateEmployeePersonalInfoOperations.addNew();
        operation.EmployeeID = employee.EmployeeID;
        operation.NationalIDNumber = employee.NationalIDNumber;
        operation.BirthDate = employee.BirthDate;
        operation.MaritalStatus = employee.MaritalStatus;
        operation.Gender = employee.Gender;
    
        dws.ApplicationData.saveChanges();
    };

    At the moment there is only one data workspace supported so use a read-only screen as 'saveChanges' will do as it is named!

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Proposed as answer by Xpert360 Thursday, May 8, 2014 5:49 PM
    • Marked as answer by Angie Xu Tuesday, May 13, 2014 9:15 AM
    Thursday, May 8, 2014 5:48 PM

All replies

  • Hi,

    That example is using a Silverlight client (desktop/web rich client).

    Some equivalent javascript code would look like this:

    myapp.EmployeesListDetails.UpdateEmployeeInfo_execute = function (screen) {
    
        var dws = screen.details.dataWorkspace;
        var employee = screen.Employees.selectedItem;
    
        var operation =
            dws.ApplicationData.UpdateEmployeePersonalInfoOperations.addNew();
        operation.EmployeeID = employee.EmployeeID;
        operation.NationalIDNumber = employee.NationalIDNumber;
        operation.BirthDate = employee.BirthDate;
        operation.MaritalStatus = employee.MaritalStatus;
        operation.Gender = employee.Gender;
    
        dws.ApplicationData.saveChanges();
    };

    At the moment there is only one data workspace supported so use a read-only screen as 'saveChanges' will do as it is named!

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Proposed as answer by Xpert360 Thursday, May 8, 2014 5:49 PM
    • Marked as answer by Angie Xu Tuesday, May 13, 2014 9:15 AM
    Thursday, May 8, 2014 5:48 PM
  • Thanks Dave!!


    reagrds PriyaMat

    Thursday, May 8, 2014 6:59 PM