In this example we will show you how you can use app-stitch to add important validations you might have forgotten in the development process. And meanwhile also introduce you to variables in the process. More precisely, we will show you how to validate if the property size is bigger than the lotsize, if so then stop any further action.
We recommend deleting the first rule created in this tutorial because you will work with the same data. Go to the rules overview page and click the red cross next to the rule to delete it. After that click on create new rule to start the next example. The purpose of this rule will be to show you that you can validate newly added records with app-stitch. In this guide we are going to show you how to check if the propertysize is bigger than the lotsize. Let’s start by analyzing our needs again:
- If a listing is created or modified that has it’s propertysize > lotsize
- Stop the action.
Start off the same way you did in our first example by starting the rule when a new listing is added. So click on the Application Data category to start.
And just like last time the rule starts when there is an action on a Listing.
This time the rule will not just trigger when a listing is created, but also when it is modified. Because you don’t want users to first add a valid listing, and then change it to an invalid one. So change the Action event to ‘Created or Modified’.
Now it’s time to start playing with the filter and the variables. You can add a filter to the action by adding a filter pattern. This means that the rule will only apply to the listings that pass the filter. And for this example, that’s exactly what you need! You don’t want to stop the action when any listing is created, we only want to stop the action when a listing is created where the propertysize is bigger than the lotsize. To access individual fields of the listing you can click the variable button.
After clicking the variable button a new popup screen will open to show you all the variables. Besides the fields of the action you are configuring you can also find some other variables like the user that created the listing, the action (created & modified in this case) and much more. But let’s focus on the Listing fields. Open the Listing category and find propertysize. Click PropertySize to add it the filter.
It should now look something like this. When the textbox doesn’t have the focus it will show you the easy to read interface. Clicking in it will change to the editing interface. We want to check if the PropertySize is bigger than the LotSize. So before we add the LotSize variable click in the textbox and add a “>”. As soon as you click in the textbox you will see the editing interface.
It should now look something like this. Now add the LotSize variable by clicking on the variable button again.
Open the Listing category again and find LotSize. Click it to add it to the filter formula.
Your filter should now look like this. This means that only listings that pass the filter will continue to trigger this rule. This completes our first step of the rule. Click accept properties.
Select the ‘then’ action type to add a new action.
Just like in the last example, you now want to stop the action. But this time it will only stop the action for listings that pass the filter. So go to Application Data, and choose the “stop the action” action.
you can play around with variables a little bit more by making the stop message more dynamic and fun. Adding variables will show them in a different font so you can easily see them. In the message itself they will be replaced with the actual values. Play around with it and try to create a message like this:
Sorry <the user that created the listing>, the propertysize <value of the propertysize> can not be bigger than the lotsize <value of the lotsize>. When you are done click the Accept properties button.
We don’t want to add another action, so let’s finish the rule.
Give it a proper Name and description and click the Create rule button to create this new rule.
And to finish the second tutorial off, Test it out by creating or modifying a listing that has a bigger propertysize than lotsize.
– 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.