HOW TO: Not allow a user to add multiple items of a meeting at the same time & date in a Calendar list for a user in SharePoint 2010

Published May 01 2019 03:29 PM 109 Views
Microsoft

First published on TECHNET on Aug 01, 2012

This post is a contribution from Bharat Rathod, an engineer with the SharePoint Developer Support team.

By default, SharePoint 2010 allows you to add multiple items in the calendar for the same date and time.  Below screenshot shows that Meeting1 and Meeting2 occur at the same date and time for the same user.

In real world scenario, we do not let a user have multiple entries of meetings at the same date and time.  For example, Outlook warns the user of the clashes of the meeting that occur at the same date and time.

Here’s a sample feature that will prevent this from occurring in your Calendar list.

The Feature.xml file

<?xml version="1.0" encoding="utf-8"?>


<Feature Scope="Site"


Title="Simple Event Handler Registration"


Id="853A4952-122D-4F97-8239-A2B02FFFDA68"


xmlns="http://schemas.microsoft.com/sharepoint/">


<ElementManifests>


<ElementManifest Location="Elements.xml"/>


</ElementManifests>


</Feature>





The Elements.xml file





<?xml version="1.0" encoding="utf-8"?>


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">


<Receivers ListTemplateId="106">


<Receiver>


<Name>doublemeeting</Name>


<Type>ItemAdding</Type>


<SequenceNumber>10001</SequenceNumber>


<Assembly>doublemeeting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30c59cdee5e7a547</Assembly>


<Class>doublemeeting.PreventDoubleBooking</Class>


<Data></Data>


<Filter></Filter>


</Receiver>


<Receiver>


<Name>doublemeeting</Name>


<Type>ItemUpdating</Type>


<SequenceNumber>10001</SequenceNumber>


<Assembly>doublemeeting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30c59cdee5e7a547</Assembly>


<Class>doublemeeting.PreventDoubleBooking</Class>


<Data></Data>


<Filter></Filter>


</Receiver>


</Receivers>


</Elements>





And the complete code file





using System;


using System.Collections.Generic;


using System.Linq;


using System.Text;


using Microsoft.SharePoint;





namespace doublemeeting


{


public class PreventDoubleBooking : SPItemEventReceiver


{


/// <summary>


/// This event is triggered when the user adds a new item


/// </summary>


/// <param name="properties"></param>


public override void ItemAdding(SPItemEventProperties properties)


{


//Our query string variable


string strQuery = null;





try


{


//Get the Sharepoint site instance


using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))


{





//Get the collection of properties for the Booking item


SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;





//Get the Calendar List that we will be querying against


SPList calendar = oWebsite.Lists[properties.ListId];





//Get the internal name of the fields we are querying.


//These are required for the CAML query


string start_internal = collItems.List.Fields["Start Time"].InternalName;


string end_internal = collItems.List.Fields["End Time"].InternalName;


string Category_Internal = collItems.List.Fields["Category"].InternalName;





//Get the query string parameters


string start_str = properties.AfterProperties[start_internal].ToString();


string end_str = properties.AfterProperties[end_internal].ToString();


string Category_str = properties.AfterProperties[Category_Internal].ToString();





//Construct a CAML query


SPQuery query = new SPQuery();





//Create the CAML query string that checks to see if the booking we are attemping


//to add will overlap any existing bookings


strQuery = string.Format(@"





<Where>





<And>


<Or>





<Or>


<And>


<Leq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Leq>





<Gt>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Gt>


</And>





<And>


<Lt>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Lt>





<Geq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Geq>


</And>


</Or>





<Or>


<And>


<Leq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Leq>





<Geq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Geq>


</And>





<And>


<Geq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Geq>





<Leq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Leq>


</And>


</Or>





</Or>





<Eq>


<FieldRef Name='Category' />


<Value Type='Choice'>{2}</Value>


</Eq>





</And>





</Where>


<OrderBy>


<FieldRef Name='EventDate' />


</OrderBy>


", start_str, end_str, Category_str);





//Set the query string for the SPQuery object


query.Query = strQuery;





//Execute the query against the Calendar List


SPListItemCollection existing_events = calendar.GetItems(query);





//Check to see if the query returned any overlapping bookings


if (existing_events.Count > 0)


{


//Cancels the ItemAdd action and redirects to error page


properties.Cancel = true;





//Edit the error message that will display on the error page


properties.ErrorMessage += "This booking cannot be made because of one or more bookings in conflict. <BR><BR>";





//Here you can loop through the results of the query


//foreach (SPListItem oListItem in existing_events)


//{


// ....


//}





properties.ErrorMessage += "Please go back and schedule a new time.";


}





}


}


catch (Exception ex)


{


//Cancels the ItemAdd action and redirects to error page


properties.Cancel = true;





//Edit the error message that will display on the error page


properties.ErrorMessage = "Error looking for booking conflicts: " + ex.Message;


}





}





/// <summary>


/// This event is triggered when the user edits an calendar item


/// </summary>


/// <param name="properties"></param>


public override void ItemUpdating(SPItemEventProperties properties)


{





string strQuery = null;





try


{





//Get the Sharepoint site instance


using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))


{





//Get the collection of properties for the Booking item


SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;





//Get the Calendar List that we will be querying against


SPList calendar = oWebsite.Lists[properties.ListId];





//Get the internal name of the fields we are querying.


//These are required for the CAML query


string start_internal = collItems.List.Fields["Start Time"].InternalName;


string end_internal = collItems.List.Fields["End Time"].InternalName;


string Category_Internal = collItems.List.Fields["Category"].InternalName;


string guid_internal = collItems.List.Fields["GUID"].InternalName;





//Get the query string parameters


string start_str = properties.AfterProperties[start_internal].ToString();


string end_str = properties.AfterProperties[end_internal].ToString();


string Category_str = properties.AfterProperties[Category_Internal].ToString();


string guid_str = properties.AfterProperties[guid_internal].ToString();





//Construct a CAML query


SPQuery query = new SPQuery();





//Create the CAML query string that checks to see if the booking we are attemping


//to change will overlap any existing bookings, OTHER THAN ITSELF


strQuery = string.Format(@"





<Where>


<And>





<And>


<Or>





<Or>


<And>


<Leq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Leq>





<Gt>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Gt>


</And>





<And>


<Lt>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Lt>





<Geq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Geq>


</And>


</Or>





<Or>


<And>


<Leq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Leq>





<Geq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Geq>


</And>





<And>


<Geq>


<FieldRef Name='EventDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>


</Geq>





<Leq>


<FieldRef Name='EndDate' />


<Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>


</Leq>


</And>


</Or>





</Or>





<Eq>


<FieldRef Name='Category' />


<Value Type='Choice'>{2}</Value>


</Eq>





</And>





<Neq>


<FieldRef Name='GUID' />


<Value Type='GUID'>{3}</Value>


</Neq>





</And>





</Where>





<OrderBy>


<FieldRef Name='EventDate' />


</OrderBy>


", start_str, end_str, Category_str, guid_str);





//Set the query string for the SPQuery object


query.Query = strQuery;





//Execute the query against the Calendar List


SPListItemCollection existing_events = calendar.GetItems(query);





//Check to see if the query returned any overlapping bookings


if (existing_events.Count > 0)


{





//Cancels the ItemAdd action and redirects to error page


properties.Cancel = true;





//Edit the error message that will display on the error page


properties.ErrorMessage += "This booking cannot be made because of one or more bookings in conflict. <BR><BR>";





//Here you can loop through the results of the query


//foreach (SPListItem oListItem in existing_events)


//{


// ....


//}





properties.ErrorMessage += "Please go back and schedule a new time.";


}





}


}


catch (Exception ex)


{





//Cancels the ItemAdd action and redirects to error page


properties.Cancel = true;





//Edit the error message that will display on the error page


properties.ErrorMessage = "Error looking for booking conflicts: " + ex.Message;


}





}





}


}



Below are the source code and the feature file samples for your reference.



 

 

 



 

Sample source code: DoubleMeetingSource

 

 



Hope this post was helpful!

%3CLINGO-SUB%20id%3D%22lingo-sub-509667%22%20slang%3D%22en-US%22%3EHOW%20TO%3A%20Not%20allow%20a%20user%20to%20add%20multiple%20items%20of%20a%20meeting%20at%20the%20same%20time%20%26amp%3B%20date%20in%20a%20Calendar%20list%20for%20a%20user%20in%20SharePoint%202010%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-509667%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Aug%2001%2C%202012%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThis%20post%20is%20a%20contribution%20from%20Bharat%20Rathod%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team.%3C%2FP%3E%0A%3CP%3EBy%20default%2C%20SharePoint%202010%20allows%20you%20to%20add%20multiple%20items%20in%20the%20calendar%20for%20the%20same%20date%20and%20time.%26nbsp%3B%20Below%20screenshot%20shows%20that%20Meeting1%20and%20Meeting2%20occur%20at%20the%20same%20date%20and%20time%20for%20the%20same%20user.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20892px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111401iEC1643970240694E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20real%20world%20scenario%2C%20we%20do%20not%20let%20a%20user%20have%20multiple%20entries%20of%20meetings%20at%20the%20same%20date%20and%20time.%26nbsp%3B%20For%20example%2C%20Outlook%20warns%20the%20user%20of%20the%20clashes%20of%20the%20meeting%20that%20occur%20at%20the%20same%20date%20and%20time.%3C%2FP%3E%0A%3CP%3EHere%E2%80%99s%20a%20sample%20feature%20that%20will%20prevent%20this%20from%20occurring%20in%20your%20Calendar%20list.%3C%2FP%3E%0A%3CP%3EThe%20Feature.xml%20file%3C%2FP%3E%0A%3CDIV%20id%3D%22codeSnippetWrapper%22%3E%0A%3CDIV%20id%3D%22codeSnippet%22%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFEATURE%20scope%3D%22%26quot%3BSite%26quot%3B%22%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ETitle%3D%22Simple%20Event%20Handler%20Registration%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EId%3D%22853A4952-122D-4F97-8239-A2B02FFFDA68%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Exmlns%3D%22%3CA%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%3C%2FA%3E%22%26gt%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CELEMENTMANIFESTS%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CELEMENTMANIFEST%20location%3D%22%26quot%3BElements.xml%26quot%3B%2F%22%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FELEMENTMANIFEST%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FELEMENTMANIFESTS%3E%3C%2FFEATURE%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EThe%20Elements.xml%20file%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22codeSnippetWrapper%22%3E%3CBR%20%2F%3E%3CDIV%20id%3D%22codeSnippet%22%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CELEMENTS%20xmlns%3D%22%26quot%3B%26lt%3BA%22%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%22%3E%3CA%20href%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.microsoft.com%2Fsharepoint%2F%3C%2FA%3E%22%26gt%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CRECEIVERS%20listtemplateid%3D%22%26quot%3B106%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CRECEIVER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CNAME%3Edoublemeeting%3C%2FNAME%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CTYPE%3EItemAdding%3C%2FTYPE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSEQUENCENUMBER%3E10001%3C%2FSEQUENCENUMBER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CASSEMBLY%3Edoublemeeting%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D30c59cdee5e7a547%3C%2FASSEMBLY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CCLASS%3Edoublemeeting.PreventDoubleBooking%3C%2FCLASS%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDATA%3E%3C%2FDATA%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFILTER%3E%3C%2FFILTER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FRECEIVER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CRECEIVER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CNAME%3Edoublemeeting%3C%2FNAME%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CTYPE%3EItemUpdating%3C%2FTYPE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSEQUENCENUMBER%3E10001%3C%2FSEQUENCENUMBER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CASSEMBLY%3Edoublemeeting%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D30c59cdee5e7a547%3C%2FASSEMBLY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CCLASS%3Edoublemeeting.PreventDoubleBooking%3C%2FCLASS%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDATA%3E%3C%2FDATA%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFILTER%3E%3C%2FFILTER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FRECEIVER%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FRECEIVERS%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FELEMENTS%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EAnd%20the%20complete%20code%20file%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22codeSnippetWrapper%22%3E%3CBR%20%2F%3E%3CDIV%20id%3D%22codeSnippet%22%3E%3CBR%20%2F%3Eusing%20System%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20System.Collections.Generic%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20System.Linq%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20System.Text%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20Microsoft.SharePoint%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Enamespace%20doublemeeting%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Epublic%20class%20PreventDoubleBooking%20%3A%20SPItemEventReceiver%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3CSUMMARY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20This%20event%20is%20triggered%20when%20the%20user%20adds%20a%20new%20item%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3C%2FSUMMARY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3COBJECT%3E%3CPARAM%20name%3D%22%26quot%3Bproperties%26quot%3B%22%20%2F%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Epublic%20override%20void%20ItemAdding(SPItemEventProperties%20properties)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FOur%20query%20string%20variable%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20strQuery%20%3D%20null%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Etry%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20Sharepoint%20site%20instance%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20(SPWeb%20oWebsite%20%3D%20new%20SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20collection%20of%20properties%20for%20the%20Booking%20item%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPListItemCollection%20collItems%20%3D%20oWebsite.Lists%5Bproperties.ListTitle%5D.Items%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20Calendar%20List%20that%20we%20will%20be%20querying%20against%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPList%20calendar%20%3D%20oWebsite.Lists%5Bproperties.ListId%5D%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20internal%20name%20of%20the%20fields%20we%20are%20querying.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FThese%20are%20required%20for%20the%20CAML%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20start_internal%20%3D%20collItems.List.Fields%5B%22Start%20Time%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20end_internal%20%3D%20collItems.List.Fields%5B%22End%20Time%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20Category_Internal%20%3D%20collItems.List.Fields%5B%22Category%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20query%20string%20parameters%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20start_str%20%3D%20properties.AfterProperties%5Bstart_internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20end_str%20%3D%20properties.AfterProperties%5Bend_internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20Category_str%20%3D%20properties.AfterProperties%5BCategory_Internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FConstruct%20a%20CAML%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPQuery%20query%20%3D%20new%20SPQuery()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCreate%20the%20CAML%20query%20string%20that%20checks%20to%20see%20if%20the%20booking%20we%20are%20attemping%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2Fto%20add%20will%20overlap%20any%20existing%20bookings%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EstrQuery%20%3D%20string.Format(%40%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CWHERE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'Category'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'Choice'%22%3E%7B2%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FWHERE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CORDERBY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FORDERBY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%22%2C%20start_str%2C%20end_str%2C%20Category_str)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FSet%20the%20query%20string%20for%20the%20SPQuery%20object%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Equery.Query%20%3D%20strQuery%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FExecute%20the%20query%20against%20the%20Calendar%20List%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPListItemCollection%20existing_events%20%3D%20calendar.GetItems(query)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCheck%20to%20see%20if%20the%20query%20returned%20any%20overlapping%20bookings%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20(existing_events.Count%20%26gt%3B%200)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCancels%20the%20ItemAdd%20action%20and%20redirects%20to%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.Cancel%20%3D%20true%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FEdit%20the%20error%20message%20that%20will%20display%20on%20the%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%2B%3D%20%22This%20booking%20cannot%20be%20made%20because%20of%20one%20or%20more%20bookings%20in%20conflict.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FHere%20you%20can%20loop%20through%20the%20results%20of%20the%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2Fforeach%20(SPListItem%20oListItem%20in%20existing_events)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%20....%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%2B%3D%20%22Please%20go%20back%20and%20schedule%20a%20new%20time.%22%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Ecatch%20(Exception%20ex)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCancels%20the%20ItemAdd%20action%20and%20redirects%20to%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.Cancel%20%3D%20true%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FEdit%20the%20error%20message%20that%20will%20display%20on%20the%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%3D%20%22Error%20looking%20for%20booking%20conflicts%3A%20%22%20%2B%20ex.Message%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3CSUMMARY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20This%20event%20is%20triggered%20when%20the%20user%20edits%20an%20calendar%20item%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3C%2FSUMMARY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%2F%20%3CPARAM%20name%3D%22%26quot%3Bproperties%26quot%3B%22%20%2F%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Epublic%20override%20void%20ItemUpdating(SPItemEventProperties%20properties)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20strQuery%20%3D%20null%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Etry%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20Sharepoint%20site%20instance%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eusing%20(SPWeb%20oWebsite%20%3D%20new%20SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20collection%20of%20properties%20for%20the%20Booking%20item%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPListItemCollection%20collItems%20%3D%20oWebsite.Lists%5Bproperties.ListTitle%5D.Items%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20Calendar%20List%20that%20we%20will%20be%20querying%20against%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPList%20calendar%20%3D%20oWebsite.Lists%5Bproperties.ListId%5D%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20internal%20name%20of%20the%20fields%20we%20are%20querying.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FThese%20are%20required%20for%20the%20CAML%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20start_internal%20%3D%20collItems.List.Fields%5B%22Start%20Time%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20end_internal%20%3D%20collItems.List.Fields%5B%22End%20Time%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20Category_Internal%20%3D%20collItems.List.Fields%5B%22Category%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20guid_internal%20%3D%20collItems.List.Fields%5B%22GUID%22%5D.InternalName%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FGet%20the%20query%20string%20parameters%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20start_str%20%3D%20properties.AfterProperties%5Bstart_internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20end_str%20%3D%20properties.AfterProperties%5Bend_internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20Category_str%20%3D%20properties.AfterProperties%5BCategory_Internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Estring%20guid_str%20%3D%20properties.AfterProperties%5Bguid_internal%5D.ToString()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FConstruct%20a%20CAML%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPQuery%20query%20%3D%20new%20SPQuery()%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCreate%20the%20CAML%20query%20string%20that%20checks%20to%20see%20if%20the%20booking%20we%20are%20attemping%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2Fto%20change%20will%20overlap%20any%20existing%20bookings%2C%20OTHER%20THAN%20ITSELF%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EstrQuery%20%3D%20string.Format(%40%22%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CWHERE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3COR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B0%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FGEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EndDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'DateTime'%22%20includetimevalue%3D%22'TRUE'%22%3E%7B1%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FOR%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'Category'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'Choice'%22%3E%7B2%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CNEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'GUID'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CVALUE%20type%3D%22'GUID'%22%3E%7B3%7D%3C%2FVALUE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FNEQ%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FAND%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FWHERE%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CORDERBY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CFIELDREF%20name%3D%22'EventDate'%22%3E%3C%2FFIELDREF%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FORDERBY%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%22%2C%20start_str%2C%20end_str%2C%20Category_str%2C%20guid_str)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FSet%20the%20query%20string%20for%20the%20SPQuery%20object%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Equery.Query%20%3D%20strQuery%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FExecute%20the%20query%20against%20the%20Calendar%20List%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESPListItemCollection%20existing_events%20%3D%20calendar.GetItems(query)%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCheck%20to%20see%20if%20the%20query%20returned%20any%20overlapping%20bookings%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20(existing_events.Count%20%26gt%3B%200)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCancels%20the%20ItemAdd%20action%20and%20redirects%20to%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.Cancel%20%3D%20true%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FEdit%20the%20error%20message%20that%20will%20display%20on%20the%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%2B%3D%20%22This%20booking%20cannot%20be%20made%20because%20of%20one%20or%20more%20bookings%20in%20conflict.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%22%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FHere%20you%20can%20loop%20through%20the%20results%20of%20the%20query%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2Fforeach%20(SPListItem%20oListItem%20in%20existing_events)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%20....%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2F%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%2B%3D%20%22Please%20go%20back%20and%20schedule%20a%20new%20time.%22%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Ecatch%20(Exception%20ex)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FCancels%20the%20ItemAdd%20action%20and%20redirects%20to%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.Cancel%20%3D%20true%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%2F%2FEdit%20the%20error%20message%20that%20will%20display%20on%20the%20error%20page%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3Eproperties.ErrorMessage%20%3D%20%22Error%20looking%20for%20booking%20conflicts%3A%20%22%20%2B%20ex.Message%3B%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%3C%2FOBJECT%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EBelow%20are%20the%20source%20code%20and%20the%20feature%20file%20samples%20for%20your%20reference.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22scid%3Afb3a1972-4489-4e52-abe7-25a00bb07fdf%3A7f8d9505-23b0-413f-8107-1adf1d32bfc4%22%3E%0A%3CP%3EFeature%3A%20%3CA%20href%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2FTNBlogsFS%2Fprod.evol.blogs.technet.com%2FCommunityServer.Blogs.Components.WeblogFiles%2F00%2F00%2F00%2F93%2F50%2Fmetablogapi%2F6305.feature_6756FE0C.zip%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20DoubleMeeting%20Feature%20%3C%2FA%3E%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22scid%3Afb3a1972-4489-4e52-abe7-25a00bb07fdf%3Aceff1f32-a78b-4535-aa17-d80de3180e78%22%3E%0A%3CP%3ESample%20source%20code%3A%20%3CA%20href%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2FTNBlogsFS%2Fprod.evol.blogs.technet.com%2FCommunityServer.Blogs.Components.WeblogFiles%2F00%2F00%2F00%2F93%2F50%2Fmetablogapi%2F1018.doublemeeting_7FE69B5C.zip%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20DoubleMeetingSource%20%3C%2FA%3E%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EHope%20this%20post%20was%20helpful!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-509667%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Aug%2001%2C%202012%20This%20post%20is%20a%20contribution%20from%20Bharat%20Rathod%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-509667%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Sep 01 2020 02:21 PM
Updated by: