>Creating a reservation application in SharePoint without writing code

>

One of the great things of the SharePoint platform is the fact that it is possible to create applications without writing any line of code. In this example I create an application to handle all kinds of (IT) reservations. A user on a desk wants to register all the laptop, camera of keyboard reservations and track their status.

We will use the out-of-the-box building blocks of SharePoint and SharePoint Designer. This example will work in SP2007 and SP2010.

We start with creating a new empty site (Site actions –> create new site (emtpy site))

Lists

We will need only 3 custom lists:

  1. reservations items: contains the items that a user can rent.
  2. reservations: contains the reservations of the users
  3. contracts: a document library that contains the contracts

Let’s create those list and their columns:

  • Reservation items
    • Title column (text)
    • Available (boolean): a check to see if the item is available at this time.
    • Location (text)
    • Deposit (Currency)
    • Daily rent price (Currency)
  • Reservations
    • Title column (text)
    • Employee (Person)
    • Reservation item (LookUp to reservation items list)
    • Startdate (Date)
    • Enddate (Date)
    • Status (Choice): values: reservation, away and closed
  • Contracts:
    • Employee (Person)
    • Location (Text)
    • Reservation item (LookUp to reservation items list)
    • Daily rent price (Currency)
    • Deposit (Currency)
    • Startdate (Date)
    • Enddate (Date)
    • Total (Currency)
    • Number of days (Number)
    • calcTotal (Calculated column)
    • calcNumberOfDays (Calculated column)
    • Responsible (Person)

De Contracts document library contains a word document as content type (template) where we design our reservation contract. When we create a new reservation a contract is automatically created in that library (by starting a workflow made in SharePoint Designer). We use another workflow to duplicate the calculated fields because a calculated field is not available as metadata in the word document. Use the following formulas for the calculated columns:

  • calcNumberOfDays
    • =[Enddate]-[Startdate] (show as number)
  • calcTotal
    • =([calcNumberOfDays]*[Daily rent price]) + [Deposit]

Now we have to create a template document. So, open Word and create a default contract, save it to your desktop as a .docx file.

image

This video shows how you can change the default document template of the document library
This video shows how you add the metadata to the document template.

Workflows

Now everything is set up we can start creating the workflows. We want to be able to make a reservation and let the employee one day before the end date know that he has to return his item. After the reservation input we have to mark the item as “not available” so that we know what items are available and what items are not. We call this workflow the “reservation automatic reminder

WorkflowSP2010_Reservation_Init

The image above shows the steps in the workflow:

  • The workflow will be started by the creation of an item in the list.
  • We start with a check of the status of the reservation. When the status is equal to “closed” we set a variable to mark that we have to close the workflow and write something to the history (just to show how to work with variables, an educational aspect here Winking smile)
  • If the startdate is greater then the creationdate we have to wait.
  • Next we mark the reservation item as not available…
  • and we wait until a day before the enddate to …
  • send a reminder email to the employee.

Let see how I did this:

Create the workflow.

The next step is create a workflow to put the reservation contract in the document library, we call this workflow: create contract

This workflow is easy:

  • Create a new item in the library, the magic of SharePoint will create you a document. We just have to fill in the columns. The Word document template will do the rest.
Create the contract workflow.

Earlier in this post I said that you cannot use the calculated fields in the Word document. Therefore we create a second workflow (start when a contract is created) to duplicate those fields. We call that the duplicate contract fields workflow:

Create the duplicate fields workflow.

Finally we have to do one more thing. When the items return we change the field in the reservation list. At that time we want to change the item to set it available again. We do this with a final workflow on the reservations list (onChange):

Set the item availability.

That’s it. The only thing you can do now is create some views on the reservation list so that we can view the current reservations, the items that must be back today, …

There are still some things that could be better (more checks in the workflows, …) but I hope this gives you an example of the possibilities of the SharePoint platform.