I am having a custom K2 form for SharePoint calendar list. I am having a drop down field which holds the list of meeting rooms. The value of the drop down is a look up from another SharePoint list. My requirement is, If user 1 is creating an event by selecting one meeting room from the drop down, and user 2 trying to create an event on the same date and same time, the meeting room drop down should not list down the value which is selected by the user 1.
I'm totally new to K2. Please let me know how to achieve this in K2?
If I am understanding you correctly, you have two users filling out a form at the same time. If User 1 selects Meeting Room 1 from the dropdown, you would like it to be removed from User 2's dropdown list. The first thing I see here is that we will have some timing issues. I don't know of way to dynamically keep a record for which rooms a user has selected as they both fill out the form. However, we can add a validation check to the submit button on the form. This will compare the current values to the ones in the list. Then it will raise a flag if that date/time and room no have already been selected. Here are the steps I would take:
1) I recommend creating a SmartBox SmartObject that has properties/columns for Room No, Used, Time/Date, ID. We will call this SMO1
2) Add a DataLabel to the Form - lets call it USED1. In the General settings uncheck the 'Visible' checkbox. We are going to use this invisible datalabel as a condition for our validation.
3) On the forms submit button, we are going to add the Action is: "Execute a SmartObject Method" and set it to "then on SMO1 SmartObject, execute its Get List Items method". We are going to configure the rules Input Mappings to take Room Number Drop Down control value and Data/Time. The Output mappings we are going use the Used Return Property from our SmartObject in step 1.
4) Next, we add the Condition: "a control does not contain a value" and we set it to, "if USED1 does not contain a value"
5) In this IF statement, we add the "then execute the Create method". This should be the existing create method for your form. We need to configure this method to also create a value in the Used Column. One of the input properties for the rule should be our Used Column from the SmartObject, hard code a '1' for its mapping. This is going to be our invisible flag if already have that room being occupied at that date and time.
6) Now we add an ELSE condition and inside the else condition we add a message to the user. The message will say something like, "The Meeting Room you selected is already occupied at that date and time. Please choose a different room or change the time or date of your meeting."
These should provide you with a similar functionality. I have uploaded a screenshot of my rules.