stephstuffaria posted: " Hello All I'm back again working on adding some finishing touches to the basic functions of the front end of my app. Last time I had run into a problem where I had removed the water changes column from my database which caused errors to occur in my ap"
I'm back again working on adding some finishing touches to the basic functions of the front end of my app. Last time I had run into a problem where I had removed the water changes column from my database which caused errors to occur in my app even when the relevant fields were not being used in the app in any way. This problem has now resolved itself, I'm not sure why (if anyone has any detail on this I'd be interested to know), but it seems just leaving it for a few days let it update what it needed to in order to stop giving that error. So today I need to finish off the Edit Species Screen and add some functionality to the buttons on each screen so the app can be fully navigated.
The first step I'm taking is copying the Back and Save buttons from the Edit Plant screen to the Edit Species screen, and editing the formulas so they point at the relevant form. I'm still having a problem from last time where the Water Schedule field is showing as blank, I'm hoping that by re-saving the data through this form it will be in the correct format to show.
Now that I've done that I'm trying to save the data for this Nasturtium with the Water Schedule set to Every 2 Days but once saved it is still showing as blank. In order to try and troubleshoot why this is occuring I'm adding an extra formula to the edit button on the View Species List screen to create a collection for the data for that item so I can see what Power Apps is getting as the Water Schedule for it.
Looking at the data in the collections screen I cannot see any obvious mismatch between what is in that field and what is allowed in the schedule table. However, while going back and forth I noticed that the Fertilising Schedule was also not appearing correctly, so it is not just a problem with the Water field but all the schedule fields most likely. I managed to fix the problem with the Fertilising Schedule by updating the Default property for the drop down element to look up the schedule ID based on the default for the parent card which automatically pointed to the current item's fertilising schedule. When I tried to duplicate this solution for the Water Schedule I realised that this wasn't using a drop down element but a combo box element which is why the same solution wasn't working. Since I no longer needed the multi-select features of the combo box I'm going to swap this for a drop down. Since I had actually originally had this as a drop down and left this invisible in the background it was thankfully easy to swap them and update the update property on the data card to reflect this.
Since this appears to have fixed the problem I will make the same change in pruning schedule also, which will finish off the changes needed for this screen. My next step is to go through each of the add/view screens and change the formula in the home button to actually navigate to the home screen. Then it's time to create the menu for these screens.
To do this I'm moving over to the Components section of the Tree view and creating a new component that is the same width as my app but not quite the same height so some room will be left at the top for the menu and home buttons. I then need to turn on the Access app scope so that my buttons can actually access the various screens in the app to be able to navigate to them. I'm also giving this component a solid filled background so when it is visible the normal elements for that screen will end up hidden behind it.
Now that my menu component has been created I can go through and add it to each relevant screen. To do this I go to the screen and in the Insert ribbon I click on Custom and select the menu component I created. Then I move it into the correct position on the screen, in my case at X:0, Y:100. Then I need to set the visibility to be controlled by clicking on the menu button, for this I need a variable that will decide whether the menu is on or not, I am calling this variable menuOn. I then set the Visible property of the menu component to be just this variable so if menuOn is true then the menu will show, if it is false then it will not. Right now this won't do anything because we have not set the menuOn variable. I am using the below formula in the OnSelect property of the menu button to switch the menuOn variable to false if it is true and switch it to true if it is false.
If(menuOn, Set(menuOn,false),Set(menuOn,true))
The final steps for the menu are making sure it closes once we click on one of the buttons to navigate to another screen and making sure the menuOn variable is initially set to false when we start our app. To achieve the former I go back to the Components section and modify the buttons to add on the below formula after the navigate.
Set(menuOn,false)
Typically to do the latter I would also add this same formula to the OnStart property of the app, however, I have recently read that the OnStart property is to be phased out so I'm going to need to put this elsewhere along with all the other formulas I use here. Because my home screen doesn't use the menu I can just add the formula to each navigation button there. For the other formulas in my OnStart I need to work out something else. Because these are gathering collections to be used in various screens and they don't need to be re-done unless a data update has occurred I don't want to run them everytime I navigate somewhere from the home screen. In order for this to work I'm using an If statement which checks if one of the collections I'm creating is blank or an error and only running the formula to clear and collect them if it is.
If(IsBlankOrError(allSpecies),Concurrent(ClearCollect(allSpecies,ShowColumns('Plant Species',"crbbb_speciesname"),{crbbb_speciesname:"Add new species"}),ClearCollect(fertPrunSched,{crbbb_scheduleid:""},{crbbb_scheduleid:"Add new schedule"},ShowColumns('Plant Schedules',"crbbb_scheduleid")),ClearCollect(waterSched,ShowColumns('Plant Schedules',"crbbb_scheduleid"),{crbbb_scheduleid:"Add new schedule"})))
Because these collections have already been created while building the app so far I need to remove the formula from the OnStart property, save and publish the app, close and re-open in order to test if this works correctly. When I restart the editor I check the Collections view to make sure there's no data currently in there, which there is not. I then click on one of the navigation buttons let it load the page and check the collections again, and it did not work...
Thankfully, a small change to the formula fixes this problem. Turns out I should use IsEmpty for this instead of IsBlankOrError. With that the basic front end functionality of my app is complete, I can now add, edit and view data and navigate easily between the various screens. My next steps will be adding the additional functionality through flows to be able to set the notifications/reminders.
For anyone wondering about the plants I spoke about last time, they're mostly doing well. I had to try again with the dwarf sunflowers because even though some of them germinated they died off again without getting bigger than a seedling, I think I may have over watered them...
Now for the real question, will I be able to keep the new batch of dwarf sunflower seedlings alive?
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.