locked
How to set entity properties value in myapp.entity.beforeApplyChanges event RRS feed

  • Question

  • How to set entity properties value in .beforeApplyChange event at client side. Thanks for your help.

    -SK


    SK

    Monday, May 20, 2013 2:05 AM

Answers

  • i figured out, here it is.

    screen.[Your Entity].details.properties.[Property].value = [value to set];

    Thank you.


    SK

    • Marked as answer by kadiyam Monday, May 20, 2013 2:48 AM
    Monday, May 20, 2013 2:48 AM

All replies

  • i figured out, here it is.

    screen.[Your Entity].details.properties.[Property].value = [value to set];

    Thank you.


    SK

    • Marked as answer by kadiyam Monday, May 20, 2013 2:48 AM
    Monday, May 20, 2013 2:48 AM
  • Unfortunately, this did not work for me. I have r.details is undefined.

    My table (entity) is called Test and I am trying to alter the Classroom value.

    The relationship is as follows: One Test has many Classrooms. I used the code below and also passed a Classroom_Param from a different screen that I am trying to assign to Classroom in the new screen.

    screen.Test.details.properties.Classroom.value = screen.Classroom_Param;



    • Edited by Mabz Sunday, August 4, 2013 9:21 PM
    Sunday, August 4, 2013 9:20 PM
  • @SK - while you can setting non-navigation type properties this way, you don't need to usually.

    Using your example, you should be able to use:

    screen.[Your Entity].PropertyName = [value to set];

    @Mabz - to set a navigation property (which is what you get when there's a relationship between two tables), you need to use the following syntax:

    screen.[Your Entity].setPropertyName([value to set]);

    Notice the "set" prefix. LightSwitch supplies both a "set" & a "get" method for each navigation property for an entity;


    Yann Duran
         - Co-Author of Pro Visual Studio LightSwitch 2011
         - Author of the  LightSwitch Central Blog

    FREE Download: Luminous Tools for LightSwitch
    (a Visual Studio productivity extension for LightSwitch)
     
    Click Mark as Answer, if someone's reply answers your question
    Click  Vote as Helpful, if someone's reply is helpful
     
    By doing this you'll help everyone find answers faster.

    Wednesday, April 9, 2014 3:34 AM
    Moderator