As we already know, form elements settings define how things look on the form. These settings live down here in the Format section of the Properties palette. Here we can set typefaces and colors for an element title and a value. Let’s, for example, set the Number value color to this beautiful blue. And this is what we will get. But what if we want the appearance to change at the runtime depending on some conditions? This is what we’re going to discuss today.
The first place where the conditional appearance settings live is right here - at the bottom of the form properties. So, let me show you one simple example first. Say, I want to highlight the Amount paid value if it’s greater than $100. This is what I do to make that happen. I’m adding a new setting to the list and selecting the red text color here. Then I’m specifying the condition like this. And now I’m telling the form which element to apply these settings to. And this is what it looks like now.I’m adding a new line to the document, the total amount paid gets over 100, and here we go: this field value is now all red and highlighted.
OK. Now let’s take a closer look. So, this is a list of all conditional settings we want applied. The conditions are checked by the form one by one from the top down. If the same field is formatted more than once, the latter setting always overrides the former. So, if I add another setting exactly like this one but with the blue instead of the red, the blue wins hands down. Every list item represents a bunch of appearance options that will be applied to a bunch of form elements as soon as this condition is met.
So, let me switch off the first item and replace this condition here with something easier to meet, so we could play with the appearance options over here.
This part up here applies to almost any form element including form fields and table columns, while these guys down here are for the table columns only. But don’t you worry. If you try to apply a setting to a wrong element, nothing bad will happen. Actually, nothing will happen at all. The setting will be ignored, and that’s it.
So, this is what I’m gonna do. I’m going to change a bunch of options at once, apply these settings to every form field and every tabular section column, and see what pops up. Now I’m changing the payment method to cash in order to meet the condition, and here we go.
OK, let’s see what’s where. So, this is our Azure background appeared everywhere except for these two read-only fields. All values are now red because of this Text color setting. Their font has also changed, and they got centered inside their fields. As for the format, it cut off everything after the decimal point only for the table values but didn’t do much for field elements outside of the table. And of course, as soon as I change this value, so it doesn’t meet the condition anymore, the default appearance returns. Anyway, this is the idea and I hope you got it.
Only two more options are worth mentioning: Visibility and Show. They work only for tables, so I’m deleting all form fields and all table columns but this one, switching the Visibility option off, and here we go. As soon as the condition is met, the Unit price column just disappears. And now it’s back again. Let’s try the Show option instead, and this is what happens. The Unit price column is here, but no values are shown. And now they are back.
So, these were the appearance options. Now let’s take a look at the conditions.
OK. Let me switch that off and add another conditional setting to the list. I want it to highlight the document number when the payment method is Cash, like this. What happens if I add another condition that checks if the Additional Info attribute contains the word "warning"? This is what. The number stays blue when the Cash payment method selected but gets highlighted as soon as I type "warning" in here. So, when I use several conditions like these the "and" logical operation is implied between them, so all of the conditions need to be met for the settings to be applied. But what if I need "OR" instead?
In this case I have to create a new "OR" group and place the conditions inside so that now there is the logical "OR" between them. Now the number gets highlighted when either payment method is equal to Cash or the Additional Info attribute contains "warning."
So, the groups work as brackets that also define what logical operation needs to be performed inside of them. And, of course, I can use as many groups as I need, embed groups into each other and do whatever else I can come up with. If you are not sure how exactly your way-too-complex condition will work, you can copy-paste it from here to any text editor and make sure it does what you want it to.
So, these were the conditions and how they work. Just one more thing before we let this topic go - the dynamic list conditional appearance.
Working with the Sales document form, we use the form’s conditional appearance settings to change how any form element, including this product list down here, looks like. This is exactly what we are supposed to do if the list is static, which it is because it’s a tabular section. This is not the case with the document list form like this one because this list is dynamic.
We’re going to discuss what exactly this static-dynamic thingy means in the very next episode, so bear with me. For now, let’s just note that the dynamic list has its own conditional appearance options and we always should use them instead of the form options. Let’s, for example, highlight all documents with the amount paid over 100 dollars, like this. And here we go - these documents are highlighted. And here is one of the main reasons why we should use the dynamic list settings over the form ones. Now a user can change these settings at the runtime. For example, a user can change the highlight color like this, or switch it off altogether like this. This is how we change form elements appearance depending on some conditions.