After some deep investigation, I can confirm the following:
- the resource field (
SPFieldFacilities
) is a special type of SPFieldLookup
(it derives from it) and the AllowMultipleValues
flag is internally set to true and cannot be modified through the UI. It could be modified via PowerShell, and it would behave like a normal lookup field, but the Check Double Booking feature wouldn't work anymore.
- if you only want to force it to allow only one selection (even though I believe that's not the full story and what you really need is to forcibly set it to some value...at least, this is my scenario, but I digress -I'll blog about this sooner or later), then the solution involves a hack as dirty as hell, which is hijacking one of the javascript function that takes care of handling the two select list boxes events (I'm referring to the two boxes next to the Add/Remove buttons)
The function to overwrite is GipAddSelectedItems
and the following is the amended code you'll want to insert in the NewForm.aspx page, preferably inside the content place holder with ID PlaceHolderBodyAreaClass
:
GipAddSelectedItems = function (master)
{ULSc04:;
// HACK *********************************************************
// remove all the selections from the box on the right
for(var i=0; i < master.resultControl.options.length; i++){
master.resultControl.options[i] = null;
}
//***************************************************************
var handler=master.addControl.getAttribute("onbeforeadd");
if (handler !=null && handler !="")
{
if (!eval(handler+"(master)"))
return;
}
var needToAdjustResultBox=false;
if (master.resultControl.offsetWidth < master.candidateControl.offsetWidth)
{
needToAdjustResultBox=true;
}
var dirty=false;
var pos=-1;
for (var i=0; i < master.candidateControl.options.length; i++)
{
if (master.candidateControl.options[i].selected)
{
if (!dirty)
pos=master.resultControl.length;
master.resultControl.options[master.resultControl.length]= GipNewOption(
master.candidateControl.options[i].text,
master.candidateControl.options[i].value);
// HACK **********************************************************
// never remove items from the candidate box (the one on the left)
//master.candidateControl.options[i]=null;
dirty=true;
// as we don't remove anything anymore, no need to decrement
//i--;
// ***************************************************************
}
}
if (dirty)
{
GipSetHiddenControlValue(master);
if (pos >=0)
{
master.resultControl.options[pos].selected=true;
GipSelectResultItems(master)
}
}
handler=master.addControl.getAttribute("onafteradd");
if (handler !=null && handler !="")
{
eval(handler+"(master)");
}
}