Set related property in Javascript when property changes (half way there)

Hi,
I have a timesheet entity and it has a related property called holiday. When the user is entering the date on the timesheet, I want the app to check if a holiday has been authorised for this date and if it finds a record then assign the found record to the
holiday property on my timesheet.
Here is my js code:
myapp.AddEditTimesheetHoliday.created = function (screen) {
// If a holiday or bank holiday is chosen, set times and other fields.
function onDatePropertyChanged() {
myapp.activeDataWorkspace.ApplicationData.HolidaysByUserAndDateRange(screen.TimesheetHoliday.HolidayDate).execute().then(function (result) {
var holiday = result.results[0];
screen.TimesheetHoliday.Holiday = holiday;
screen.TimesheetHoliday.addChangeListener("HolidayDate", onDatePropertyChanged);
By debugging in IE I can see the json returned and I can see my var holiday gets populated as I'd expect. However, on my screen I have some of those related properties on screen so that when it's populated they should be updated to give some valuble information
to the user.
This is my problem though. Despite the code seemingly working fine, the related controls on the screen do not show the fetched data. Here is my screen:
Am I right to asume that:
screen.TimesheetHoliday.Holiday = holiday;
would refresh the bindings on the html screen? If not, then is there a way in which I can do this?
Thanks in advance.
Paul.

Hi Paul,
Try adding the HolidaysByUserAndDateRange query to the screen with results returned as one. Will need code adjusting if multiple. Bind the parameter to
TimesheetHoliday.HolidayDate.
Then...
myapp.AddEditTimesheetHoliday.created = function (screen) {
// If a holiday or bank holiday is chosen, set times and other fields.
function onDatePropertyChanged() {
screen.getHolidaysByUserAndDateRange().then(function (result) {
var holiday = result.results[0];
screen.TimesheetHoliday.Holiday = screen.HolidaysByUserAndDateRange;
screen.TimesheetHoliday.addChangeListener("HolidayDate", onDatePropertyChanged);
I hope it all magically works.
Dave
ps: just seen your answer, but if you find that you start having problems with unsaved data and transaction boundaries then try this as it will resolve it.
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.

Similar Messages

  • I tried to open a folder in my Documents. It does not show in any window but does show up when I am half way between windows. It did the same thing when I tried to empty the trash. It asked if that was what I wanted but I could't say yes because it was or

    I tried to open a folder in my Documents. It does not show in any window but does show up when I am half way between windows. It did the same thing when I tried to empty the trash. It asked if that was what I wanted but I could't say yes because it was or

    what is your question/issue here? did the folder have any content in it to begin with? screen shots of what you may be seeing?
    if english isn't your native language, write it in what you are most comfortable speaking in to describe your issue.

  • What do I do when I'm half way through a movie on Apple TV.  The movie then quits.  We go back on to the movie home page and it says you have already rented this movie, please go to settings, then downloads and select downloads but we can't find downloads

    What do I do when I'm half way through a movie on Apple TV.  The movie then quits.  We go back on to the movie home page and it says you have already rented this movie, please go to settings, then downloads and select downloads but we can't find downloads

    Try signing in and out of itunes on apple tv, do you have lastet OS?

  • Itunes match, when it's half way through matching, can it be stopped

    Hi
    I've started to install itunes match on my Desktop this morning, at lunchtime, it was a quarter of the way through, if it hasn't finished by tonight, can I turn my PC off, and then it'll resume next time I turn on the PC, or does it have to finish first.

    During the matching or uploading part you mean? If it's the uploading part then the answer is yes. That's what I did last year. It took me close to three weeks back then to get my whole catalog matched & uploaded and I couldn't leave the computer switched on so I shut it down during daytime and let it run when I was at home. 
    When you restart the process each time you see that fewer songs get uploaded than with the previous run.

  • The ios7 is not updating through the computer and when it get half way it says that there is an error. I cannot try through wifi because I don't have the software update tab. If anyone could help it would be good.

    Doesnot work through the computer
    Cannot update through wifi
    There is an error everytime it updated through the computer

    Hello there, Adele102.
    The following Knowledge Base article offers up some great steps for resolving the issue you're describing:
    Resolve iOS update and restore errors in iTunes
    http://support.apple.com/kb/ts1275
    If the issue persists, then this article provides an extensive list of error messages and additional troubleshooting steps:
    Resolve specific iTunes update and restore errors
    http://support.apple.com/kb/ts3694
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Why does "Please insert a duel-layer disk" pop up when I'm half way through burning a DVD in FCP X?

    I work for a Sports Media company and it is important to burn our games to DVD as quickly as possible. Everytime FCP X is halfway through the burning of the DVD (each game is about 1-1.5 hours long) that pop up about the duel-layer disk comes up. What is that? I never had a problem doing this before. Also what other kind of DVD is there? What is better to use? Thanks a lot!

    No catch that I know of - just more content (and more expensive). I don't use FCP X, but is there a screen where you can check the size of your project? In iDVD, I can see my project here:
    With that I can keep track of the size.

  • Free download for acrobat pro fails when it is half way through the download

    free 30 day trial download for acrobat pro fails half way through, help

    Try downloading the installer from https://helpx.adobe.com/acrobat/kb/acrobat-downloads.html
    Phone support is limited to Mon-Fri daytime; outside this you can use chat via Contact Customer Care.

  • Core data: making object related to another object when a property changes

    ok, say with core data I have object1 and it has a to-many relationship with object2
    and when property1 if object1 changes then the number of/contents of the related object2 changes as well
    think of a box of chocolate... object1 is the box and object2 is the chocolate... object1 has a string property that is the colour of the chocolate and when it changes the chocolate objects need to change accordingly
    maybe not the best example but you guys should get the idea
    I'm not sure how to do this without causing errors
    what I did initially was this:
    -(NSString*)words {
    printf("retrieving words
    [self willAccessValueForKey: @"words"];
    NSString* s = words;
    [self didAccessValueForKey: @"words"];
    return s;
    -(void)setWords: (NSString*)newWords {
    printf("setting words
    [self willChangeValueForKey: @"words"];
    words = newWords;
    [self didChangeValueForKey: @"words"];
    - (void)setNilValueForKey:(NSString *)key {
    printf("in nil value
    if ([key isEqualToString:@"words"]) {
    self.words = @"";
    else {
    [super setNilValueForKey:key];
    which has broken the redo
    I went ahead anyway and redone the setWords
    -(void)setWords: (NSString*)newWords {
    [self willChangeValueForKey: @"words"];
    words = newWords;
    [self didChangeValueForKey: @"words"];
    // NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
    // [[managedObjectContext undoManager] disableUndoRegistration];
    NSArray* linesWords = [newWords componentsSeparatedByString: @" "];
    NSSet* newContainsWords = [NSSet set];
    [self removeContainsWords: self.containsWords];
    for(unsigned int i = 0; i < [linesWords count]; i++) {
    NSEntityDescription* entity = [NSEntityDescription insertNewObjectForEntityForName: @"AtomWord"
    inManagedObjectContext: managedObjectContext];
    AtomWord* wordEntity = (AtomWord*)entity;
    wordEntity.word = [linesWords objectAtIndex: i];
    newContainsWords = [newContainsWords setByAddingObject: wordEntity];
    [self addContainsWords: newContainsWords];
    // [managedObjectContext processPendingChanges];
    // [[managedObjectContext undoManager] enableUndoRegistration];
    this too also broke the redo
    I uncommented the undo manager stuff to see what would happen, thinking it would group everything together for the undo-redo
    but instead it made two copies of object1...
    what's the best way to do this?

    I don't see an option to upload images so I'm going to assume you can see this ascii representation of it
    |----------------| |----------------|
    | Line | | Word |
    |----------------| |----------------|
    |v Attributes | |v Attributes |
    |lineOfWords | |theWord |
    |----------------| |----------------|
    |v RelationShips | |v RelationShips |
    |madeUpOf |<----->>|containedIn |
    |----------------| |----------------|
    lineOfWords and theWord are string properties
    when lineOfWords changes I need the set of Words it contains to change to reflect the change in lineOfWords
    The reason I need words to be an entity itself is because each word has attributes (not shown there) that are specific to each word
    This is how I made the schema, I'm not sure how or if you can reflect the relationship between the property and list or if there is a better way to do it...

  • When i change the value of a combo box using a property node it displays the value not the item label

    I am using a combo box as a select list for text serial commands.  I have items like "engineering", "GUI", and "Scan" for the commands "MDE", "MDN", and MDS respectively which i have input as the corresponding value in the combo box.  so for example the label "engineering" has the value "MDE" in the combo box items list.  when the Vi starts it needs to read the current value MDE, MDN, or MDS and then i want it to display on the front panel the item text corresponding to that command value.
    To do this i have tried to read the serial command, ie MDS and then wire that to a "value" property of a property node of the combo-box, but instead of displaying the corresponding item label, "Scan", it displays the value "MDS" on the front panel instead.  i want the front panel to use the label text when choosing and displaying but the block diagram to use the serial commands.  Can this be done with a combo box?  I'm trying to use a combo box so i can keep it all text and avoid having to build a case statement to convert enums or rings from a numerical value to the text command.
    The correct text value is wired to the value property and it does exist in the combo-box.  I have unchecked "values match items" and selected to not allow undefined values.

    Don't use the value property node.  Use the Text.Text property node.  When creating the property node, select Text, then in the next pop-up box, select Text.
    - tbob
    Inventor of the WORM Global

  • How to update a baen property through javascript?

    I am creating a shuttle listbox component where i copy a value from one listbox(source) to another listbox(target) onclick of a button using javascript.
    when i click on the submit button i want the setter property of the target listbox to be updated using javascript.
    i dont want to use ajax.
    is there an option how i can achieve this?
    please help me...

    It sounds like this is more of a JavaScript question than a Java question. The JavaScript source code available here may help.

  • I am trying to set up app tabs, but when I am using one, if I go to a new site from there, the app tab changes to the new site instead of opening in a new tab, then the app tab changes to the new site. Can you help? Thanks

    I am trying to set up app tabs, but when I am using one, if I go to a new site from there, the app tab changes to the new site instead of opening in a new tab, then the app tab changes to the new site. i.e. The app tabs don't stay constant. This occurs while still in Firefox, and does not relate to when I close it. Has anyone got any ideas? Thanks

    If you backed up the iPhone to either iTunes or the iCloud, restore the backup. If not, the data is gone.
    (126342)

  • Property binding causes Bean property to be null when Component is readonly

    I am retrieving an object (instantiation of a Bean) from a list of objects displayed in a table.
    A set of components (textfields, textareas) are bound to the properties of the retrieved object. - propertybinding, text property bound to name property of managed bean.
    If I make any of the bound components read-only the corresponding property of the bound object is set to null.
    Why is this? Is there a work-around for this? If there is not I will not be able to make use of the propertybinding feature and I will have to populate and retrieve from components manually.
    I have tested this using different components and setting up binding in multiple ways - through "data binding" and through "property binding" directly to the text field of the component.
    Thanks,

    I have been working with my issue for a little bit and I've learned that binding to an object (or Bean) can be dangerous for the object.
    In SessionBean1 I have instantiated two objects of my bean TransferMethod, tm1 and tm2. tm2 is a "copy" of tm1 in that it contains all the same data, but in separate memory.
    I've bound tm1 to text fields on my jsp page. tm2 is not bound to anything.
    My page has a table, and edit area and several buttons. When I load my page it populates the table with data. I select a row from the table and click my "Edit" button. This instantiates the tm1 and tm2 objects and populates them with data from the row.
    As my text fields are bound to tm1 the text fields are now populated when the page is re-displayed. The name field is bound to the name property and the component is set to readonly. The description field is bound to the description property and has no other configuration.
    When I click my "Save" button and interrogate my tm1 and tm2 objectsm all properties in my tm1 object are reset to default values with the exception of the description field. All properties of the tm2 object are still populated with original data.
    This tells me that binding an object to components is not feasible if you expect to continually work with that object on a single page.
    My work around will be to manually assign the properties of my object to my textfields and vice-versa.
    Hopefully the new version of Creator will address this issue.
    Rebecca

  • After successful install, all my adobe cc docs, when open, change pointer arrow, i-beam and window to oversize. When doc closes all return to normal size. I'm on a PC. Screen res set to medium 1920x1200. Any ideas how to fix?

    After successful install, all my adobe cc docs, when open, change pointer arrow, i-beam and window elements to oversize. When doc closes all return to normal size. I'm on a PC. Screen res set to medium 1920x1200. Any ideas how to fix?

    Ok thanks Linxup I would recommend posting in the respective forums for each of those software titles as opposed to the Creative Cloud Download & Install forum.  The relevant forums are as follows:
    InDesign - InDesign
    Illustrator - Illustrator

  • I set my passcode in arabic then I changed the language to English, when I wanted to open my ipad later there was no arabic letters to enter my arabic passcode..and I am not able to use my Ipad again please let me know what to do

    I set my passcode in Arabic then I changed the language to English, when I wanted to open my ipad later there was no Arabic letters to enter my Arabic passcode..and I am not able to use my Ipad again please advice me what to do

    Hello Shaholeh87,
    Do you see a Globe icon on left hand side of your Spacebar if yes try pressing that and see if you get an option of changing the keboard language (this will work if you have Multiple language set on your iPhone from Settings>General>Keyboard>International Keyboards and added a keyboard in Arabic Language before )
    Or you can get your iPhone in Recovery Mode and Restore it to Factory settings but you will lose all your current Data that you have on your iPhone.
    To Restore your iPhone by taking it in Recovery Mode you can follow the below steps :
    Follow the process mentioned below step by step to get your iPod Touch/iPhone/iPad working.
    Make sure you have Latest Version of iTunes (11.1.3) Downloaded and Installed on your Computer, if not then you can download the latest version of iTunes from the Link below.
    http://www.apple.com/itunes/download/
    Now once you have the Updated version of iTunes installed on your computer follow the below steps to get your iPod Touch/iPhone/iPad in Recovery Mode and Then restore it to factory settings
    Open iTunes Application on your computer and then start the process step by step
    1>Disconnect your device from the computer (if connected). The process won’t work if you start with the iPod Touch/iPhone/iPad connected to the computer. Leave the cable connected to the iPod Touch/iPhone/iPad, as you will be reconnecting the iPod Touch/iPhone/iPad to the Computer later in the process.
    2>Power down your device. Turn off your device by holding down the Power button ( On Top right corner of iPod). When the power slider appears, slide it to the right. Wait for your device to comepletely shut down before continuing.
    3>Press and hold the Home button (Home Button is located at bottom of your iPod Touch/iPhone/iPad screen/display). With the Home button held connect the device to your computer with the USB cable. When reconnected, your device should turn on.
    (If the low battery screen appears, charge your device for a few minutes and try the process again.)
    4>Continue holding the Home button. After a few moments, you will see the "Connect to iTunes" screen on your device. This screen is a picture of an arrow pointing from a USB cable to the iTunes logo. When you see the screen you can release the Home button.
    5>iTunes will display a message stating that a device in recovery mode has been connected. From there you can proceed to restore your iOS device. Once you see this message click on OK and then click on Restore
    Once you click on Restore iTunes will download the Latest available version of iPod Touch/iPhone/iPad software (ipsw file) in your computer and after the download is completed the same will be restored in your iPod Touch/iPhone/iPad. You will see the Download process and Restore process on top of your iTunes screen. Once the restore is completed your iPod Touch/iPhone/iPad will automatically restart and you will see a message that iPod Touch/iPhone/iPad has been Restored and will connect after restart.
    Now you will have to follow some steps on your iPod Touch/iPhone/iPad to Customize your Device for First Use.
    Hope this process will help you

  • My iphone 3gs has started showing the wrong time  and date. All was fine until this afternoon when it changed.  My apps have the right time and date. However the world clock is wrong. I have to turn off the automatic time setting to get the right time.

    My iphone is showing the wrong time and date. All was well until sometime this afternoon when it changed...  to Nov 5 (2 days prior to today), and about 9 hours and some minutes before the actual time.  The world clock for my time zone shows the same wrong date and time. My calender shows the same wrong date and time.  The phone can not find my time zone any more.   The only fix I found was to turn off the automatic setting for time.  What is  happening? Ideas?

    just sorted mine went to
    settings-mail,contacts,calender-timezone support
    then turned it off then on tapped time zone and typed london
    this did sort mine

Maybe you are looking for

  • No Profit center field capture while Capital Down Payment

    when we are making a capital asset down payment using a down payment request, system is not able to pick up the Profit center in case profit center of bank is different from Profit center of asset. what could be the reason for this. 001 50       0024

  • Error when Create Materialized View

    Hi When I tried to create MV show me error : SQL> @CRIA_MV_ARC_BW.SQL AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3) ERROR at line 88: ORA-01031: insufficient privilegesI am using Oracle 9.02 and there are Grant for all Tablles , my query of cr

  • Itunes library.itl can't be opened

    when i want to open itunes, the messages "itunes library.itl can't be opned since it had been configuered by a newer itunes version (or similar, it's written in German) does anybody know anything about this?

  • Windows 7 CD issues

    Hi, Saw a few other questions with similar problems but not the same as this. Whenever I try to copy a CD using iTunes all songs copy fine except the last one, my computer freezes and I have to do a hard reboot, this also happens if I only select the

  • Link MM document with FI document

    Hi all, We have a problem. We can't link the controlling document with billing document (financials document): 1. In FB03 we can view financials document and  the link to controlling document with  Menu -> Enviroment -> Document Enviroment -> Origina