Example1: Authorizing who can continue to create a new record

posted in: documentation | 0

For our first introduction we’ll show you how to make a new rule that checks if a user has permission to add a new listing. If they do not have the right permissions, the action will be blocked. Let’s first analyze this step by step. It consists out of three parts:

  1. If a new listing is added
  2. Check the user permission
  3. Stop the action

Creating an app-stitch rule is always about analyzing your needs. After analyzing it step by step, creating your rule will be a walk in the park!

So now that you know that our first step will be to start the rule when a new listing is added. Adding a record is part of the Application Data. So that’s where you’ll have to start. Click on the Application Data event.

Image 001

Now you see all the possible actions. These actions depend on your own data sources and will be different in your own application. A pet store could for example have an action here “Action on Pet” or “Action on Vaccination”. But for now, keep focusing on our test app. The first part of the rule was “If a new listing is added”. So click on the Action on Listing.

Image 002

For this example just leave it on created. But you can of course change it to anything you like. Play around with it as you want. For now you can ignore the Filter property and the variable button next to it. We will explain that in a later example. Once you are ready, click the accept properties button to go to the next step.

Image 003

this completes the first step of our rule. Now you have to decide the action type. For this example there is only one option so it’s pretty clear what we have to click. You are probably thinking ‘what are these action types?’ Don’t worry! We’ll explain all that to youlater. For now, just click the ‘Then’ action.

Image 004

Now you’ll find yourself on a screen similar to the one you started on. Note that on the bottom of the screen you can see your rule so far by hovering over the Application Data in the footer bar. The second step of our rule is “Check the user permission”. User permissions is also a part of the Application Data.

Image 005

As you can see the options have now changed. You can choose to change the Listing that is just added. This can be useful when you want to set some default values for example. We’ll explain more and other types later but let’s first finish this rule. Now the permission has to be checked to see if the user has the rights to create this listing.

Image 006

Here you can adjust these properties as you like. Again we suggest you play around with these. In this guide we’ve decided to configure the rule that if the user does not have the role LightSwitchApplication.PremiumPropertyScout then he will not be able to add the listing, but feel free to play around with this yourself . After this, click the accept properties to finish our second step.

Image 007

As you can see there are now two action types already. You can either finish the rule or add another action. Since you are still missing step three of our rule, Add another action. So click the ‘Then’ button again.

Image 008

Step 3: “Stop the action”. Because you want to stop the user from adding this record, you will again have to go to the Application Data category.

Image 009

So far the rule is: “When action on Listing then check for permission”. Now you want to block the action by stopping it.

Image 010

Fill out an appropriate message to be displayed, we don’t want the users to be confused what is happening now do we. Click on Accept properties when ready to finish the rule.

Image 011

Now that you have completed the three steps of our rule, it’s time to finish it. You can add as many actions as you want. An example of another action you could add would be to create an audit record, or send an email. But for this example, Just finish the rule.

Image 012

Complete the rule be adding a description and changing the name if you’d like to. When ready, click on the Create rule button.

Image 013

Congratulations on creating your first rule. You can click on it to see all the details.

Image 014

And now there’s only one thing you left you have to do. Test it! Go back to the test application and try to add a new listing. Go back to the example application and click on the list a home button on the bottom right.

Image 015


– 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.