Course registration with List formatting

Recently Tetsuya and Michel shared some great examples of a new option in List formatting. You can now use a setValue action within List formatting.

courseregistration

Course Registration

One of the examples I have seen a lot on the Power Automate community is registration or sign-up in a SharePoint list. A lot of times a Power Automate flow would be needed to meet the requirements in these kind of scenarios. In this article I am going to show you can use the setValue action to meet most of your requirements without the need of building a flow.

Assume we have the following requirements:
– A user can register for one or several courses
– A course has a number of available places, when all places are taken registration is not possible
– There is a registration end date, after this registration is not possible

SharePoint Online list

First of all you would need to create the SharePoint Online list and the columns. To give you a head-start a create a PnP PowerShell script for this. Feel free to reuse it (at your own risk ;)).

Change format Register column

1. Navigate to your newly created list and click Column settings > Format this column.

formatthiscolumn

2. Insert the json below and click save.

Explanation of the json

First we try to handle the showing/hiding of the register button. This is done in the display property of the div.

In this formula I am using a conditional operator if(). In that if statement I am checking if three things are all true.

1. If the e-mail of the person who is creating the list item is not registered. This expression is using a IndexOf binary operator and a @me special string value. When the expression returns -1 it hasn’t found the e-mail and the button will still be shown.
2. It will compare the length unary operator to check the number of people registered for the current course. When that isn’t equal the number of available places the register button will still be shown.
3. If the current date is before the registration date the register button will still be shown. The @now special string value is used for this.

In the bottom of the json I am using the same expressions only in individual divs and the true false values will be in reserve. This is to show a custom message when one of the conditions is met.

And finally the start of this blog, the customRowAction with a setValue. In this case I am using a appendTo binary operation to add the person who is creating the list item to the existing list of people who registered.

Happy testing!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.