1

I´m doing a course catalog app for sharepoint. And i have a list called Courses. in that list i have two columns called: seats and FreeSeats. When you make a new course the boss decide how many can apply to the course. So for ex: 5 seats. When the Fifth person apply there most be a stop. So i thought if i have the column FreeSeats, it can count up everytime someone apply. And when it is the same as the column Seats it will NOT be able to apply. So i guess i need some sort of count that add 1 everytime someone apply to the FreeSeat column. And in a if loop check if the value of freeSeats are smaller than Seats, you can apply. If its bigger than Seats it will come a stop message.

Someone have any idea how a code like this looks like? I have never done this before.

jacki
  • 41
  • 4
  • What type of app? Which SharePoint version? Are you using C# or client side through JSOM? Are you using the REST api? Where are the applications saved? Be more specific. – Daniel B Dec 04 '15 at 14:01
  • a sharepoint hosted app on version 2013. Using Javascript. Im working in Visual studio and the lists and everything is saved in the project. Later when its done im going to publish it on a SP site – jacki Dec 04 '15 at 14:37

2 Answers2

0

Since your new to this I would advise you go through this MSDN tutorial.

It outlines how you would do some basic CRUD functionality in a SharePoint app.

You can then adapt it for your particular purpose. This is how I started out :) good luck. Ignore the fact it mentions Napa the app structure should be similar in VS

MSDN SharePoint CRUD in App

Cheers

Truez

Truezplaya
  • 1,315
  • 1
  • 13
  • 26
0

You can actually set this up without any code by creating a list of Free Seats with Titles ranging from 1 to #. In your signup lists you would create a lookup column for each course that points to the corresponding list of free seats and select the "Enforce unique values" option. That way, when a user signs up for the course, they must select one of the free seat values you have created, and cannot sign up for a value selected previously. You can use a workflow to update a list elsewhere to give you your signup counts for tracking if you wish.

To do this programmatically you would need a workflow or event receiver that counted the total number of list items with a Free Seats value selected and then remove the contribute rights for the list that people are using to signup. There is no other way to stop people from adding a new item once your quota is satisfied.

Arcan.NET
  • 700
  • 4
  • 12
  • thank you, but i only would like to do it in javascript. And i got it to work! :D I don´t show the FreeSeats column for the users. Just use it as a count. When FreeSeats is the same as seats it will not work to sign up for the course anymore. Just needed to make the two columns a int with IntParse and then my code worked! :D But thank you for taking your time to answer :) – jacki Dec 07 '15 at 18:49