For this next example we will show you more of the true power of variables. For this example we want to show you how to add a ‘featured banner’ across images that match some criteria. We have configured the real estate sample application that it will add this banner to all listings that have the IsFeatured field set on true. So all you have to do isfilter out all the listings that match a pattern of criteria. So the first thing you have to do is create a filter for all the listings to only have a few specific listings with a feature banner, so click on the application data channel to start.
You will work with an action on Listing again.
You only want the really good deals to be featured, so we will only feature the listings that match following criteria:
-the listing is for rent
-the listing has 3 or more bathrooms
-the listing has a price of less than 1000
To filter out only these listings, we will add a filter pattern. So let’s start by converting these criteria a little bit into a more formula.
-listing.NumberOfBathrooms >= 3
-listing.price <= 1000
To make everything more readable we recommend to add brackets around every part of the pattern. So start by adding a (. Then click on the Variable button, open listings and scroll down to IsForRent. Click on it to add it to the textfield.
Add ‘==true)’ to the formula to compare the content of this variable. This will make sure that you only have the listings that are for rent (that have the IsForRent property set on true).
There are 2 ways to combine multiple criteria into 1 formula. && and ||. && can be compared to the word AND. Adding && means that both the first AND the second criteria have to be matched. || can be compared to the word OR. It would mean that the first criteria OR the second criteria have to be matched. In this case everything should be matched so glue everything together by adding && between every criteria.
Add a new ‘(‘ to start the new criteria. Now add the part of the formula that checks if the listing has 3 or more bathrooms. Click on the variable button, open listings and find NumberOfBathrooms.
Now add ‘>=3)’ to the formula to complete this second part. So far it will filter out only the listings that are for rent and have 3 or more bathrooms.
Add && again to glue the last part of the formula together. Add another ‘(‘ and open the variables screen to find the Price variable. Add it to the formula.
Lastly add ‘<=1000’ to this last part of the formula and close the brackets. Now that you have all three parts of the formula it should look like this. Click on accept properties to accept. If you’re feeling confident, feel free to add some extra criteria! You can for example try to say that it is featured when it has 3 bathrooms OR 4 bedrooms.
Now it’s time to add the second part. So far you have filtered out all the listings according to our very specific criteria. All that is left to do now is to change the IsFeatured field of those listings to true. So click ‘then’ to start this last step.
Open the application data channel and click on the ‘Change the Listing’ action to change the listings that matched the earlier entered filter pattern.
Scroll down to find the IsFeatured field and add the word ‘true’ to it. This will change the IsFeatured field of those filtered out listings to true. We have configured the sample app to add a featured banner to all listings that have this field set to true. So the application itself will take care of the rest.
Click on Finish rule and fill out an appropriate Title and Description for your rule. Finish by clicking on create rule.
Now all that is left to do is test our new rule. Go back to the real estate sample app and click on the ‘list a new home’ button on the bottom right. Make sure that the listing type is Rent, that there are more than 3 bathrooms and that the price is lower than or equals 1000
Save your new listing and you’ll see that it has a nice Featured banner.
– application link
– Intro: sample application tour
– rule 1: Authorizing who can continue to create a new record
– rule 2: Understanding variables
– rule 3: Set a default value on new records
– rule 4: introducing channels
– rule 5: recap: audit
– rule 6: time channel, mail channel and new action types
– rule 7: audit when rule fired
– rule 8: Make a newsletter.