Posts mit dem Label SharePoint 2007 werden angezeigt. Alle Posts anzeigen
Posts mit dem Label SharePoint 2007 werden angezeigt. Alle Posts anzeigen

Freitag, 23. November 2012

Issues with Lookup-Fields with each more than 20 items

If you have multiple lookup-fields in your form which reference to more than 20 items (hardcoded limit in the LookupField-Control!), you may notice to the display and behaviour of your control:

- The rendering of the field switches from select-tag to an input-tag and an img-tag. A click on the image shows a layer with the selectfield.
- This only occures to Internet Explorer, not to Firefox.

The naughty thing on this is the issue, that the selectfield-layer appears below the first-clicked lookup-field, no matter, which lookupfield you click afterwards.

Click on the first lookup:



Click on the second lookup:



This bug can be fixed by override a function in the core.js that must be loaded immediatly in the masterpage. A good piece of working code I found here today: http://dipaktele.blogspot.de/2012/07/two-lookup-field-with-more-than-20.html

I copied the code found on this page and added it here:


function FilterChoice(opt, ctrl, strVal, filterVal) {
if (typeof (opt) != "undefined") {
var i,
cOpt = 0,
bSelected = false,
strHtml = "",
strId = opt.id,
strName = opt.name,
strMatch = "",
strMatchVal = "",
strOpts = ctrl.choices,
rgopt = strOpts.split("|"),
offSet = $(ctrl).position(),
x = offSet.left,
y = offSet.top 15,
strHidden = ctrl.optHid,
iMac = rgopt.length - 1,
iMatch = -1,
unlimitedLength = false,
strSelectedLower = "";
if (opt != null && opt.selectedIndex >= 0) {
bSelected = true;
strSelectedLower = opt.options[opt.selectedIndex].innerText;
}
for (i = 0; i < rgopt.length; i = i 2) {
var strOpt = rgopt[i];
while (i < iMac - 1 && rgopt[i 1].length == 0) {
strOpt = strOpt "|";
i ;
if (i < iMac - 1) {
strOpt = strOpt rgopt[i 1];
}
i ;
}
var strValue = rgopt[i 1];
var strLowerOpt = strOpt.toLocaleLowerCase();
var strLowerVal = strVal.toLocaleLowerCase();
if (filterVal.length != 0)
bSelected = true;
if (strLowerOpt.indexOf(strLowerVal) == 0) {
var strLowerFilterVal = filterVal.toLocaleLowerCase();
if ((strLowerFilterVal.length != 0) && (strLowerOpt.indexOf(strLowerFilterVal) == 0) && (strMatch.length == 0))
bSelected = false;
if (strLowerOpt.length > 20) {
unlimitedLength = true;
}
if (!bSelected || strLowerOpt == strSelectedLower) {
strHtml = "<option selected value=\"" strValue "\">" STSHtmlEncode(strOpt) "</option>";
bSelected = true;
strMatch = strOpt;
strMatchVal = strValue;
iMatch = i;
}
else {
strHtml = "<option value=\"" strValue "\">" STSHtmlEncode(strOpt) "</option>";
}
cOpt ;
}
}
var strHandler = " onclick=\"HandleOptDblClick()\" onkeydown=\"HandleOptKeyDown()\"";
var strOptHtml = "";
if (unlimitedLength) {
strOptHtml = "<select tabIndex=\"-1\" ctrl=\"" ctrl.id "\" name=\"" strName "\" id=\"" strId "\"" strHandler;
}
else {
strOptHtml = "<select class=\"ms-lookuptypeindropdown\" tabIndex=\"-1\" ctrl=\"" ctrl.id "\" name=\"" strName "\" id=\"" strId "\"" strHandler;
}
if (cOpt == 0) {
strOptHtml = " style=\"display:none;position:absolute;z-index:2;left:" x "px;top:" y "px\" onfocusout=\"OptLoseFocus(this)\"></select>";
}
else {
strOptHtml = " style=\"position:absolute;z-index:2;left:" x "px;top:" y "px\"" " size=\"" (cOpt <= 8 ? cOpt : 8) "\"" (cOpt == 1 ? "multiple=\"true\"" : "") " onfocusout=\"OptLoseFocus(this)\">" strHtml "</select>";
}
opt.outerHTML = strOptHtml;
var hid = document.getElementById(strHidden);
if (iMatch != 0 || rgopt[1] != "0")
hid.value = strMatchVal;
else
hid.value = "0";
if (iMatch != 0 || rgopt[1] != "0")
return strMatch;
else return "";
}
}

_spBodyOnLoadFunctionNames.push("FilterChoice");
function EnsureSelectElement(ctrl, strId) {
$("#" strId).remove();
var select = document.getElementById(strId);
if (select == null) {
select = document.createElement("SELECT");
ctrl.parentNode.appendChild(select);
select.outerHTML = "<select id=\"" strId "\" ctrl=\"" ctrl.id "\" class=\"ms-lookuptypeindropdown\" name=\"" strId "\" style=\"display:none\" onfocusout=\"OptLoseFocus(this)\"></select>";
FilterChoice(select, ctrl, ctrl.value, "");
}
return document.getElementById(strId); ;
}


After that, the select is displayed correctly:



Please be sure to include there functions in your own js-file that's loaded after the core.js and avoid modifying the original core.js.



Donnerstag, 27. Mai 2010

The template you have chosen is invalid or cannot be found


Today I solved another sharepointastic riddle. As you maybe know, it's possible to assemble a web with all lists, content and what else you need, and save it as Site Template for reuse. After that you can create new sites by gui or on programmatical way.
But be careful! If you created the .stp-File on a MOSS 2007 with Enterprise-licence, you may see this nice error-message when you try to create a site on a MOSS 2007 without Enterprise-licence (Standard-licence only):





"The template you have chosen is invalud or cannot be found". Jippiejajee Schweinebacke!
The first location I visited was the SharePoint-Logs. Very often I don't find any clues for problems but this time - oh wonder - I did:

Applying template "Deployment.stp" to web at URL "http://server/sites/test/deployment".        
05/27/2010 14:07:51.87         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           Fields                                88ys        Medium          Failed to get the site template for language 1033, search key 'Deployment.stp'. This warning is expected when provisioning from a custom web template.        
05/27/2010 14:07:53.57         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           Fields                                936z        Medium          Marking web-scoped features active from manifest at URL "http://server/sites/test/deployment"        
05/27/2010 14:07:54.41         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           General                               936x        High            Failed to mark site-scoped features active in site 'http://server/sites/test/deployment'.        
05/27/2010 14:07:54.44         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           General                               72h9        High            Failed to apply template "Deployment.stp" to web at URL "http://server/sites/test/deployment".        
05/27/2010 14:07:54.44         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           General                               72k2        High            Failed to apply template "Deployment.stp" to web at URL "http://server/sites/test/deployment", error The template you have chosen is invalid or cannot be found. 0x81071e44        
05/27/2010 14:07:54.44         w3wp.exe (0x06D4)                               0x0A14        Windows SharePoint Services           General                               8kh7        High            The template you have chosen is invalid or cannot be found.

Alright, this approved my assumption an Enterprise-feature that's not available in Standard-licence is making trouble here.
So I activated google for a page that lists the differences between Enterprise- and Standard-Features and after a while I found a helpful blogpost in the msdn:


Office SharePoint Server Enterprise Site features

Internal Feature Name:  PremiumWeb
Feature Id:  0806D127-06E6-447a-980E-2E90B03101B8
Feature Definition Id
Feature Display Name
E8734BB6-BE8E-48A1-B036-5A40FF0B8A81
RelatedLinksScopeSettingsLink
56DD7FE7-A155-4283-B5E6-6147560601EE
AnalyticsLinks
0BE49FE9-9BC9-409d-ABF9-702753BD878D
SlideLibrary
065C78BE-5231-477e-A972-14177CC5B3C7
BizAppsListTemplates (KPI List)
2510D73F-7109-4ccc-8A1C-314894DEEB3A
ReportListTemplate
00BFEA71-DBD7-4F72-B8CB-DA7AC0440130
DataConnectionLibrary

These are the features on Web-Scope that aren't available on the Standard-licenced server. The blog-post also lists Enterprise-features on SiteCollection - and WebApplication-Scope.

Now I had to look into the .stp-File. To do so, I renamed the deployment.stp to deployment.cab and extracted it into c:\temp\deployment.
I opened the manifest.xml, searched for each of the feature definition ids and removed the whole -tags. Now the tricky part came: how to get back all extracted files to a .stp without writing a .ddf-file?

Forget about MAKECAB.EXE, use CABARC.EXE! It's a tool in Microsofts Cabinet Software Development Kit; you can download it here: http://support.microsoft.com/kb/310618

The webpage on http://www3.hi.is/~snorri/SDK-docs/tools/tools008.htm lists a lot examples of how to use cabarc. So I copied CABARC.EXE into c:\temp and used this command to create my new deployment.stp-file:

c:\temp\cabarc n deployment.stp deployment\*.*

Now I have a new working .stp-file I can use as SiteTemplate to create sites on a MOSS 2007 with Standard-licence.