PL-100 Microsoft Power Platform App Maker – Create model-driven apps – charts, dashboards, card forms and business rules Part 4

  1. 45. Expanding our Dataverse business rule

Okay let’s change this amount to $600 so now we are over a hundred description should appear and no it doesn’t. OK why is description not there? Well the reason is I said what to do if the expense is under 101 said what to do if the expense is over or equal to 100 so I said set the visibility to false. I haven’t said anything anywhere. Well if you change your mind, set the visibility to true so I need now to add something else. Now, I can’t change this at the moment. And the reason I can’t edit it is because it’s activated. So this is when it might be quite useful to save it as another rule. Edit this other deactivated rule so that this rule continues. Activate the second rule.

Deactivate the first. But I don’t need to worry about people editing right now, so I’ll just deactivate it just for now. And now I will be able to edit. So what I’m going to do is I’m going to say set visibility of the description to yes so is more than 100 so let’s save that, let’s activate it. You can also see the validation is successful as food and everything and we’ll go back to our form here. So I’ll just go back refresh always useful and going to here so we can’t see a description here, change it to 600 press tab description appears so you can see instantaneous.

Now suppose the expense is more than a thousand okay, maybe we should do something else, maybe we should have a recommendation for the description. So I’m going to add another condition and you can see I can’t add another condition here conditions can only be placed as you can see in certain places. So right at the beginning so if I want to say here’s the expense is it less than 100 so now I’m going to say is it greater than 1000? So if the expense value is greater than or equal to 1000 then yes I want to set the visibility and I’ll need to do that for the false side as well.

So let’s set this visibility. But in addition so I’ll say that call that is more than 100 and this one is more than 1000 in addition here I want to have a recommendation for the description. Now, I’ve not actually got a real recommendation for description, I just want to show the process. So here we have the recommendation title so more than a thousand, this expense is more than $1,000 and apply that. But there is something within this recommendation and if I click on the details you can see there is a new action.

So in other words, I’ve just said there’s a recommendation title, there is a recommendation details. But what I want to do if the person accepts a recommendation well I want to have the description to be changed to this needs urgent reviewing a big expense so let’s apply that so now you can see the logic I’ve got. If it’s less than 100 and high description else if it’s greater than or equal to 1000, then we have a description shown and a recommendation for what that description is going to be.

Otherwise just show the description. So you can probably work out your own logic that you want for your particular tables and apps. So let’s activate that, go back into our form refresh find. That always good. So let’s see what happens. Currently we’ve got $60, $600, description appears back to $60, description disappears $6,000. We now have a light bulb next to description. If you’ve got a locked symbol or something you may need to refresh. So let’s have a look. We can see that there is a recommendation.

This expense is more than 1000, says our title, there’s a description and if I apply, then the description gets updated in line with what we have said. This needs urgent reviewing, a big expense. So hopefully you can see the sort of things that we can do with business rules. Just a few more words. First of all, we can zoom out and zoom in. We have a picture down here of what it looks like. So when we are zooming in too much for the screen, you can see the entirety anyway. You can collapse this business rule text view if you want. You can also fit to Canvas. You can get a snapshot.

So snapshot saves what you are seeing to an image. So here you can see the image that we have just created. You can cut, copy and delete certain things. So I can’t do this at the moment because it is activated. You can add by clicking on the add up here as well as dragging in the components from the right hand side. Now, you should know that not all of these seven are applicable to canvas apps. So the show and hide the set visibility or the enable and disable.

So the lock or unlock or the business recommendations, they won’t actually be used in Canvas apps. All you’ve got are the validate stored information. You’ve got the set and clear field values and you’ve got the sure error messages for invalid data. If you’ve got an error message by the way Sean, that means that the data you’ve entered will not be saved. Now, there’s just one more thing to talk about, business rules. And let’s go back to our data. So here’s our data, our table. We’re going to business rules and you can see we’ve got this business rule and how exactly do you delete it? You can deactivate it, but how to delete it? There is no delete.

If I go into relationships and click on a relationship, then depending on what relationship it is, then I should be able to delete the relationship. But here there is no delete button. So how do I delete it? Well, this is when I need to go into the Solution Explorer. So this is the classic interface so I do that just as a reminder, click on the gear. So going to settings, going to advanced settings, going to this dropdown settings and customizations and click on customize the system and then we can go into the entities. So this is the solution.

Explorer we’re going to entities going to the relevant entity, going to the relevant business rule and here we can click on it, check it and we can delete so believe it or not, the delete button is not there on the new interface but this is how you can delete a business rule.

So business rules, they allow you to apply business logic at the data layer, not the app layer. So they can be used in PowerApps, Power, Automate or in programming. To access them you go to data tables, business rules so if I add a new business rule, you can see all of these things are available for model driven apps you can also set the scope as well to all main and quick create forms or a specific main form. However, for canvas apps, we need to keep this to entity. You can validate store data, you can set and clear field values, you can show MSRs. It’s only in model driven apps that you can show or hide or enable or disable fields and create business recommendations.

  1. Practice Activity Number 11 – The Solution

So how did you get on with this practice activity? Well, at the moment we don’t have any charts for the device table, so let’s create one. So if I go back to the PowerApps portal page, go back into this particular table, the device table, make sure I’m in the right environment, and I go to charts and I add a chart. So we’re going to call this my devices chart. Notice we’ve got a view used for the chart preview. I’m going to use the my devices view that won’t actually affect how it is shown in the actual model driven app, because you’ll be looking at a view while you’re looking at a chart. So in the series, so this is the thing, you aggregate the sum.

For instance, I’m going to put the original purchase value and then I’m going to add a second series for the current value and then going across. So this is the access labels. I’m going to add the device type. So you’ll notice that we are summing the original purchase value and the current value. And we can have columns or we can have areas. I’m going to stick with column. So I’m going to save and close this, click, done. And then I’m going to refresh my model driven app, click show chart, and there is my chart. So if there are a lot of items here, then I would be seeing the summary of that. So all of the computers would be in just two bars, all of the laptops would be in another pair of bars, and so forth.

Next I’m going to create a dashboard. So it’s going to be a fairly simplistic dashboard, just make it a two column overview. So I will call this my device dashboard, and I will be adding my only chart into the photos and into the streams. I’ll be adding active devices as well as my devices view. So you can see at the top the charts are also visual filters. So I will save this, close it, go back into my model driven app. And you can see at the moment there isn’t a section for dashboards. So what I’m going to do is I’m going to publish all customizations because that seemed to work last time after creating dashboards. So that’s in the power apps portal solutions.

And we’ll be looking at this solutions page a lot later in this course. So now you can see published all customization successfully. So if I refresh this now, it’s still not sufficient to see it in the model driven app. So instead what I need to do is to go into the app designer, go into dashboards, and here we can see my new dashboard, my device dashboard. So what I’m going to do, I’m just going to make a very slight change because I prefer going not just save and close, I prefer going save and then publish. So now it has been published, I will play this and if I click on devices, you can see that we’ve now got open dashboards as an option. And here is my device dashboard. So we’ve got the active devices and my devices view, and we can show visual filters. So I can filter it down for instance, just on a particular device such as laptop. So I’ll play that filter now and hide the graphs. So the last thing I’ve asked you to do is create a new database business rule.

So if I go into business rules and add business rule, so I want a condition. So this is my value condition and the condition is that my current value field, the question is, is it greater than the field called the original purchase value? So is the current value greater than the original purchase value? If so, then I want to show an error message. So the error message will be on the current value and saying this cannot be greater than the original purchase value.

So let’s apply that. So notice I’m reading this business rule as I go along and I’ve realized I forgot to click the apply button for the condition. Very important to keep looking at it. So even if you make a mistake, you need to be able to correct it fairly swiftly, otherwise you never know what might be going on. So if the current value is greater than the original purchase value, then show an error message. So I’m now going to save this. If it isn’t, of course you don’t need to do anything. So we can validate it. Validation is successful, let’s activate it. So the scope is the entity. So this will work for canvas apps as well as model driven apps as well as others, your programming for instance.

So it’s now activating now, it’s now activated. So if I go back and refresh, you’ll see that we’ve got this new business rule. So let’s create a new device in here. So let’s click on new. So we can see we’ve got this here. So my device name is my iPad, so is my device number, is my device tab, mobile device purchased so I can put a date of purchase on whenever I want. And over I will put the original value as $100. Let’s say I got it secondhand and its current price is $200. And here you can see the big error warning error current value, this cannot be greater than the original purchase value.

So if I change it to $90, then that disappears. If I have $100 exactly the same value, that’s fine. But it’s just when I go $0. 01 over $100 and a penny, then it says no, don’t do that. So now I can save and close that. And this is my new device having been inserted. Well, I hope you enjoyed this practice activity and you really get into grips, wave, model driven apps. And that’s it for the model driven apps. For this course though, we will be coming back to it in combination with other components and other servers. Officers so, in the next section, we’re going to turn to the power automate and we’re going to start creating some flaws. Please join me there.

 

img