1. 38. The Collect function – Adding records to a collection
In this section, we’re going to have a look at the use of collections. So what are collections? Well, we’ve previously been using the Microsoft Dataverse as our data source. So that is a source on the Internet. Now, for my app to get the information, it has to communicate through the Internet, interrogate the data, and get the information back. Obviously, that takes time. What if the app on your iOS or Android device was offline and couldn’t connect to the Internet? After all, not everywhere has a good mobile phone signal. Well, one way is to have your own data source incorporated into your PowerApp, and that is called a collection. So we’re going to create a Canvas app from scratch. As you can see, I’m building the PowerApps.com canvas app from the ground up. So I’m going to call it my collection. And this is going to be in tablet format.
Obviously, if you don’t have a tablet and a form, you can format it yourself. So let’s click Create; it’ll only take a few seconds for everything to be ready. So we’re not starting with a data source in mind, but we do need to have an idea of what we’re going to do. What is the purpose of this particular app? Well, what I’m going to do is take pictures and add them to a collection. So for that, we need a camera. We can also do “Add Picture” if you want to try this from your laptop or desktop. But I’m going to use a camera. On a handheld device, the difference between Camera and AddPicture is that Camera will always give you the camera. Add Picture will give you the option of getting pictures from your library. So let’s click the camera. So there is my camera. So I’m going to rename it “Camera.” I’ll call it a device. Now I also want some text to go with this. So for this, we need text input. So I’m going to allow you to type in some text. So enter photo text here. And then what do I want to do? Well, when I click on the camera, let’s make it nice and big. When I click on the camera, it should add it to a collection. So let’s go to On Select.
So when I click on the camera, that’s the On Select event or property. So what we’re going to do is add it to a collection. And it’s very simple to do. Do we just call collect? So Collect adds an item to a collection. So first of all, it needs to know what the collection is going to be called. So this is just like a variable, so you can name it whatever you want. So my collection, let’s say, and then what is it going to collect? So because it’s going to be a record, it needs to be in squiggly brackets. So let’s close the bracket at the end. So what is it going to collect? Well, it’s going to collect a picture. So let’s call it an image, the image.And again, this is just a column, so you can call it what you will. So it’s a column within the collection. The image is going to be this. So the camera device has a dot, and you can see that it’s given me a photo. So that’s a good idea. And I also want some text. So the text is going to be, and I’m going to use this. Now, I can’t remember what this is called, so I’ll just put two quotation marks for now for “blank screen.” So this is called text input. So I’m going to call it photo description. So the text is going to be a photo description. And I could add dot text as well. So when I click this, it goes into the collection.
So we need to be able to see the collection; otherwise, we won’t be able to know whether it’s going—you’ll just have to take my word for it. Well, we can add this to a gallery. So here is a gallery. So I’m going to use a vertical gallery. Drag this over to the right-hand side and drag it down. So it’s just going to be an image and a title. The data source is going to be my collection, which is a collection. When I go into the fields, you can see that it has an image and a title. So there’s an image and text there. Now we can also see the collections that are being used by going to File and Collections. So here’s my collection. And it’s a bit difficult to actually work with because I can’t see anything. So let’s put a dummy image up. So we’ll go to the media. I’ll upload it along with the earlier sales receipt. Why not? So that gives me an image. Now I need to populate the collection. So my collection So to do that, I go to the app, and you can see I can run the onstart. So, to begin, I’m going to give it a shot. I’m going to say, “How do I add a new item to my collection?” Collect. So Collect, you can see it’s auto-completing my collection. Comma. So what do we have? We have an image. The image is going to be, however we code it here, a sales receipt. And the text is going to be welcome in the app. There we go. So if I run on start, let’s see what happens. We now have one image added to the collection, and it’s got some text saying welcome to the app. If I run it again, you will add a second one because collect adds a raw to a collection.
Now, the collection doesn’t need to be a new one; it can be a preexisting one. Returning to File & Collections, you can see a preview of the first five items in this collection. So the collect function adds a new row to a collection. So because it is a record, strictly speaking, then we have to put it in scrutiny brackets, and then we say, “This is our column for our row or our field for our record, and this is what I want inside of it.” So that is our first step into a collection. The function collect adds a new row to an existing or new collection.
2. 38. The Clear and ClearCollect functions
In the previous video, we added a record to a collection. We did not need to initialise the collection in the same way that verbals did. We just had to say “add to a collection.” and that was sufficient to initialise it. However, we are able to add multiple rows using the on start for the app. But maybe if I didn’t want multiple rows when it started, I’d just want to have one row. I want to get rid of my collection and then add a new item. Well, I can do that with the function cleared. So specific, and which collection are you going to clear? It leaves a blank collection. However, the columns that have previously been defined—in this case, image and text—remain. So now when I run on Start, it clears the collection and then adds an additional record. Now I can combine these two into one. And that is the function. Clear, collect. So it clears the collection and then adds a record to it. Now I’m saying it adds another record to it. You could always have additional records as well.
It doesn’t need to just have one. So maybe if I wanted to have two, I could just paste it again and say, “Please capture your images.” So that would add two records. So if I run Start, there we go. Now let’s add a second screen to this. So a new screen And I’m going to put together a form for the gallery exactly as we did previously. So I’m going to add it to a form. Let’s make it a display form. It’s not connected to any data yet, so we’ll connect it to the collection, my collection, and we’ll add the field. Oh, and there’s a problem. Unfortunately, you can’t use forms with collections. It doesn’t work. So instead, we’re going to have to have a label. So going to text, there’s an identifier, and we’ll have an image. So going to the media and getting an image there Then we’ll decide which image to use for the image. Well, we’re going to have the gallery that we have in Gallery One, the row that is selected, and the image from that particular row or record. And same here. So let’s centre it and make it a little bigger.
Again, in the text property, it will be Gallery One, selected text. So this is a welcome to the app. So let’s now add a “back” icon. So maybe I’ll cancel one this time. and this will be on. Select just a simple back. And then we have this on-select, so that selects the parents. I’ll select the gallery, and we’ll go to OnSelect, and we will navigate to screen two. And we will cover. Right. So if you have a look at it now, we can go to a particular item. There you are. I think maybe cover left, which is just called cover, would be better. So let’s just change it. That right. So I’m not able to add camera images here. If I were using a picture control, I could always upload images that I’ve previously captured. But I want to be able to test it on a tablet device. So let’s save this. So we’ll save it as a collection. Click “Save” down here, bottom right. So that’s saved. So I’ll close it now and return to makepowerapps.com, where we need to refresh the list. And there is our collection. So I’m going to go back through this and edit it. And hopefully I’ll see in my browser, on the top left, that this app wants to use the camera. So let’s just have a look. So I’ll skip that sometimes. It’s on the top left here. It’s on the top right. So this camera is blocked. This page has been blocked from accessing it. No, I want to access my camera so we can see my camera here, on the webcam. So let’s click “done.” So maybe if I click on Manage and it is automatically blocked, we can see it is now allowed. So there it is. Right, we have my camera working. So I have a snowdrop. Here we go.
Mickey Mouse So I’m going to type it in here. I’m going to play Mickey. And let’s just do that again. Click that. And now we have a Mickey photograph. So if I close this down, I will leave. Done. I can play this. So you can see, she needs permission to use your camera. That’s where I was expecting it. So I’m going to click “allow” and “allow.” And here we go. So this is a live picture. We have the two records that have automatically been added. and let’s click there. There’s a third record, or I should have said Mickey. There we go; there is Mickey. Now I probably need a button to clear all of this as well. So let’s go back in and edit this again. We’ll add a button to clear the collection so we can see the camera being used. So insert a button so I can make it more curved if I want to. You can see we’ve just got curved edges.
So I’ll make it a bit more curved. You can see the board here already. So I’ll say “clear collection” and “select,” and this will be clear. Open brackets for my collection. Make it a bit more central. Make that a bit more central. Save this. You need to publish it because saving is not sufficient. You also need to publish it if you actually want to use it. Let’s return to this room and read the page from seven seconds ago. Play. And even though it’s not published, I haven’t made it live, have I? So let’s go into the details. Versions. It’s live. Okay? So let’s just go back. I can’t see the button at the bottom. Let’s edit it again. Oh, I’m still in it. That sort of blocks it. So let’s leave that. Play it again. There we’ve got the button at the bottom, so I can say, “Hello, Mickey.” And there we are. There is Mickey. Now, the problem with this is that if I go away from it and come back in again, it’s not saved. My Mickey globe is no longer here, so we can’t retain the data in the collection for the next session. We can actually do that with two functions, and we’ll have a look at those two functions, save data and load data, in the next video.
3. 38. The SaveData and LoadData functions
Now in this video, what we’re going to do is add in two more buttons: save data and load data. So we can also put load data, for instance, into the on start and then pick up from where we left off. So I’m going to edit our app. Now, there is one big caveat about saving and loading data. It does not work on.In other words, if you’re doing this on a computer or laptop, it could be a Mac or anything else. It doesn’t work. It has to be a remote device. So it has to be, for instance, an iPad, an iPhone, and an Android device, or something like that. So what I’m going to do is add a couple more buttons. So I have one button here that is going to be my Lord Data. and another button, and I’ll just make it more rounded as well. I think I used 20. I use 20. Okay. and another button I’ll just copy and paste. And let’s have these echoes be distant. Here we go. This is going to be saved data.
So the functionality is very straightforward. If I go to the Lord data on the On Select, Now you can see that it’s asking for the collection. So my collection is asking for the name of a data file in local storage, and the file is being asked for. It will, of course, save to your iPhone, iPad, or Android device. So my data and the same for saving data—the only difference is the name of the function. So now I save my collection to a local file called “my data,” right? So, as I said, I’d love to be able to test it out here, but unfortunately it won’t work on a PC. If I play, I can click the buttons, and they don’t give me an error message. So I’ll put in Mickey, add it, and save the data. Then I will go away. I’ll come back, and I’ll click to load data. In fact, we have it, and you have it here. So I need to clear the collection and our load data, but nothing happens. So what I need to do now is save it, publish it, and then let’s make sure that this version, if I refresh just to make sure I’ve got the latest, is actually live.
So let’s move on to versions. Yes, we can see it live. So what I’m going to do now is go on to my iPad and see what happens. So here I am on my mobile device, which happens to be an iPad, and I’m going to go to the collections app and click on it there. And now you can see the iPad is asking me, “Do I want to allow access to the camera?” So I’m going to say “allow” in the bottom right-hand corner. And here we are. So I can now add a photograph of Mickey. So I’ll just type Mickey up here, and I’ll press on the image. There we go. And now I’m going to get a second character. So this is a figment of my imagination. So I’ll add Figment. So what I’m going to do now is click Save data, and I’ll exit the app by dragging from the left to the right. So let’s go back into my collection app. So we just have the two default items there, which I can clear. So click on “clear collection.” But now I’m going to load the data, and we’ll have all four items that we previously had. And so now what I can do is add a fifth item. Here’s a fifth item. So call this Hey, Dougie. So I’ve added it twice. I’m not going to click Save Data this time.
I’m going to just exit and go back in. So if I clear the collection and load the data, there it is. If I load the data again, then you can see it a second time. So currently, I’m using the collect function. So maybe I should use the “clear collect” function. So let’s clear the collection and load the data again. You can see, “Hey, Doggy isn’t part of this,” because I didn’t click on “Save Data.” So I will add, “Hey, dig in!” There we go. I’ll save the data, exit the app one more time, go back in, play the collection, load the data, and there we can see all five characters. So in this video, we’ve looked at the clear and clear collect functions as they’re used with the save data and lord data. However, keep in mind that savedata and Lord Data are only available for mobile devices. So your iPhone, iPad, or Android device
4. 9. Describe standard, premium, custom connectors; Configure a connection
In the next video, what we’re going to do is take a look at a Twitter connector. So now’s a good time to take a look at perhaps lots of different types of connectors and see what’s available. But there are over 200 different connectors—in fact, maybe around 300 by now. And we can see the connectors if we go to the PowerApps portal, make PowerApps.com go down to the table, and go down two connections. So here is the connection that I’ve already made. So I’m going to click on “new connection,” and then we can see the variety of connections we have, and there are an awful lot of them. Now you could divide these connections up into three categories: standard, premium, and custom. As a result, standard connectors are typically open-source services provided by Microsoft 365 or Power Platform. So they natively integrate premium connectors. On the other hand, you can see the word “premium” all over the place, and sometimes you would see a diamond in other versions. So those both indicate premium connectors. These are usually services that require a monthly or annual licence and are not part of Microsoft 365 or the Power platform.
However, that does include the data verse. Now, premium connectors are only available with the premium Powernap’s licence or the developer plan. So, if you’re using power apps with Office 365 and don’t have a powernaps licence or developer plan, you’ll probably want access to these premium connectors. And finally, there’s custom. So these are connectors that are not built in; they’re not included in the standard or premium. It’s a connection that somebody has to design. So you can see examples of standard and premium connectors here. So let’s see what sort of things we’ve got. First of all, we’ve got Azure Active Directory. So that’s the way of establishing your identity. I suspect that because it is so widely used, that’s why they haven’t put it in the premium category. So Google Maps is now available in Dropbox. Now, that might surprise you because, hang on, you have to pay for Dropbox, and as we’ll see later, MailChimp and Server Monkey are premium. Well, that’s probably true, but Dropbox actually has a fairly generous 2 GB of free service, and that’s probably why it is in the standard connector. We’re talking Dynamics 365 customer voice, which is standard Excel and Excel online. We’re talking about the file system. In other words, your own file connection to it, anything Google-related.
So we’re talking Google Calendar, Google Sheets, and Gmail. LinkedIn Mail. Down here. Microsoft Teams and Microsoft Translator MSN.Weber, Office 365, Outlook, and Outlook.com The Power: Apps and Power The answer is yes. Bi RSS. So if you don’t know what RSS is, suppose you have a blog and you keep posting to the blog.An RSS feed keeps track of what you’ve posted. It’s available for anybody to look at, and you will find, for instance, that apps, including PowerApps, can connect to these RSS feeds. And then we’re also looking at WordPress and YouTube, all standard connectors. Now, don’t be misled; there is a type over here that says “Standard,” but as you can see, it’s standard for all of them, whereas it’s certainly not included in the premium things. So don’t be misled by the word “standard” over there. In fact, they all say “Standard.” Now, Premium Connectors usually require a monthly or annual license. Premium connectors also include the database license, which is a premium connector as well. So we’re talking about things like Adobe Creative Cloud. So obviously you do have to pay quite a lot for Adobe Azure products, but we’re not talking here about Active Directory, and we’re not talking about Sentinel.
So all the offers you can see are premium. Now when we have a look at Dynamics, you can see that Dynamics 365 Customer Voice is the only one that is a standard. All the rest are premium tools like MailChimp and SurveyMonkey. So yes, the fact is that these do have a free aspect, but to get the most out of them, you have to pay. So that could be a difference between Dropbox, which has a fairly generous 2 GB of free space, and MailChimp Survey Monkey, which is perhaps a bit more restricted. So, as previously said, we’re talking about the Microsoft database, and then we’ve got databases. So MySQL, PostgreSQL, and SQL Server the Oracle database as well. And besides me, Word Online Brackets Business is also a premium connector. So there are no custom connectors here; that’s something that someone actually has to design. Now, another way of looking at connectors is that there are connectors that provide tables. So we’re talking about Microsoft Excel, SharePoint, SQL Server, and database connectors, which provide actions and functions. So you can connect a control to an action using the item property of your control. So we’re talking about Azure BlobStorage and Connectors, which offer both. So Office 365 users and projects are online. So what they provide might impact how you can use them in power apps. So in this video, we’ve had a look at connectors and at the three different types: standard, premium, and custom. And they can provide tables, actions, and functions.
Now, once you’ve identified which connection you want to use, just go to the plus sign next to it. So let’s say I wanted to add Dropbox, and you can see it gives me more information about it. Okay, I want to create this. And then the computer is asking for permission to use the files and folders in my Dropbox if I am trying to get to Microsoft Azure. So I’m just now going to delete that one because I didn’t actually want to connect to it. But you could see that there was a problem when I tried to. So let’s say I wanted to connect to Azure Active Directory. Then again, I would need to sign in. So if this is a Microsoft product, I need to sign in with my Microsoft credentials. Again, just delete this. If this were a different product, say I wanted to sign into Google Mail, then I would have to sign in with my Google Mail credentials. So it’s very simple to implement. All you need to do is find the connector you want, click on the plus sign, and then, after accepting any terms and conditions, sign in as appropriate.
5. Practice Activity Number 8 – The Solution
So how did you find this practise activity? So all of this had to do with working with collections. So I wanted you to create a new Canvas app. So let’s make it a tablet layout. And I wanted you to write down the date of the meeting, the time of the meeting, the location of the meeting, and who was present. So I asked you to use text boxes to allow the end user to enter that data and labels for the description. So let’s introduce a few labels. So the first one is the meeting date; the second is the meeting time; the third is the meeting location; and the fourth is who the meeting was with. So with whom? I’m just going to select all of these and just extend them. So all of these labels are on one line each. So next, we need to insert a date picker for the date of the meeting. I’ve suggested that you have a text input for the time of the meeting. There are numerous ways to achieve a more professional appearance, but they are moderately complex. So we don’t need to do that. For now, we’ll just have a time of meeting text box, and then I’ll just copy the location of the meeting and with whom as well. So for each of these, I’m going to say that the default is going to be blank, and I can put it in the hint text. So time of meeting, location, and with whom As a result, attendees other than yourself So I need a button, so I need an “add” button. So let’s insert a button, and it’s just going to say “add.” Now that I’ve got OnSelect, I’ve got to use what function. I got to use the collect function.
So I’m collecting for a new collection. So the collection is called “meetings,” and the item is “date of meeting.” Well, I can have the date of the meeting, and that is this value here. So what’s this called? This is date picker number two in my case. So the date picker selected two selected date.Then we’ll have the meeting time, which will be text input, and the meeting location. That will be text input underscore one, and with whom will be text input underscore two. Blackrix clause, normal brackets So this is when it’s really good to actually have these with real names. Text time, text location, and text attendees on that date. So now that function is a lot more readable, and we can make sure we’ve got the right things in the right column of the collection. So next, I want to display this data in a date table. Data table. So I’ll click on the data table so that it is there and drag it to one side. So it’s over here. So it’s not connected to any data. So the data source is going to be the meetings collection, which has no fields at the moment. Well, I haven’t actually run this, so I probably should run it and add in a date of the meeting, a time of the meeting, a location here, and with whom you will be meeting. So click “add.” So we’ve now added something to our collection. So if I edit fields, I can add fields and add all of those. It just makes working with the data a lot easier if I can actually see some data. Now I want buttons for Clear All, Save Data, and Load Data so I can go insert a button, and this one is Clear All again. It might be helpful later on if we had names, but we don’t need to do that for now. So what is its function? That is the clear function.
So I’m clearing meetings, and then another button says “Save Data.” So this will be the Save Data function. So I’ll be saved by saving the meeting collection. And I’ll call it the “Meetings” file, for instance. And then I’ll copy that because for my button number four, which is going to be Load Data, it’s going to be exactly the same thing except it’s going to be Lord Data. Now the Save data and Load data buttons won’t actually work until they’re on a mobile device. So, as is fine, let’s just click “Save,” and I’ll call this meeting “Click Save.” So that’s done. And now I can test it on a mobile device. It took a few minutes and some refreshing, but the meetings app is now available on my iPad. So I’m just going to click on it and let’s add a few things. So, enter a time of 10:00 a.m. for our meeting with whomever you want, and then click Add. I can save the data, I can clear the data, and I can load the data as many times as I want, and then I can add additional information here if I so wish. So, I hope you enjoyed this practise activity and are getting a good handle on working with collections. So that’s the end of this part of the course that relates to canvas apps. We will be coming back to canvas applications, but in relation to other things. In the next section, we’ll be looking at model-driven apps, and we’ll start by looking at the site map and forms. Please join me there.