Thursday, February 3, 2011

SharePoint 2010: How to enable developer dashboard

$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
$addsetting.Update()

SharePoint 2010: how to get SQL rows for a document in a library

Here's the snippet, just change the doc lib name and doc title.

select * from AllDocs d
join AllLists l
on d.ListId = d.ListId
and upper(l.tp_Title) = 'UPPERCASE DOC LIB NAME'
and upper(d.LeafName) = 'UPPERCASE DOC TITLE'
join AllUserData u
on u.tp_DocId = d.Id

Tuesday, February 1, 2011

SharePoint 2010: "Access denied by Business Data Connectivity" when viewing list that accesses external data

Solution: permissions (either to users if delegation is used, or the app pool account is trusted subsystem is used) need to be assigned through Business Data Connectivity Service in Central Administration site.

Friday, January 21, 2011

ASP.Net: OnSelectedIndexChanged event not firing

I had this snippet in a page:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td>
<asp:ListBox ID="lst" runat="server" OnSelectedIndexChanged="lst_SelectedIndexChanged"></asp:ListBox>
</td>

Problem was that OnSelectedIndexChanged was not firing.

Solution was to set AutoPostBack to true in the list.

SharePoint 2010: Adding taxonomy field to files in a Document Library

Pre-requisite is that a taxonomy structure is set up with a "Term Group" group, a child "Term Set" with a "Term Name" term on it. Other than that, it's just about adapting site and list names to your deployment.

Here's the code:

        private void Test()
{
// get doc lib
SPWebApplication wa = SPWebApplication.Lookup(new Uri("http://server"));
SPSite site = wa.Sites["/sites/test"];
SPDocumentLibrary dl = site.RootWeb.Lists["DocumentLibrary1"] as SPDocumentLibrary;

// get taxonomy field
TaxonomySession session = new TaxonomySession(site, false);
TermSet set = session.DefaultSiteCollectionTermStore.sGroups["Term Group"].TermSets["Term Set"];
Term term = set.GetTerms("Term Name", 1033, false)[0];
TaxonomyField tf = dl.Fields["Term Field"] as TaxonomyField;

// add files
for (int i = 0; i < 100; i++)
{
using (FileStream fs = (new FileInfo(@"C:\Content.txt")).OpenRead())
{
// add item
string name = "Name " + i;
Hashtable ht = new Hashtable();
SPFile file = dl.RootFolder.Files.Add(name, fs, ht, true);
SPListItem item = file.Item;

// set item's taxonomy field value
tf.SetFieldValue(item, term);
item.Update();

// progress
Console.WriteLine("{0} created", name);
}
}
}

Thursday, January 20, 2011

SharePoint: The Taxonomy feature (Feature ID "73EF14B1-13A9-416b-A9B5-ECECA2B0604C") has not been activated.

Taxonomy feature is a hidden feature; it doesn't appear in the Site Collection Features UI. Enable it from SP's Management Shell:

Enable-SPFeature -id "73EF14B1-13A9-416b-A9B5-ECECA2B0604C" -url <site collection Url>

VMWare: blank screen when "use host setting for monitor" is chosen

After booting a virtual box, I started getting a blank screen after the Windows boot progress bar dissapeared. I wasn't sure what may have changed.
Went to edit VM settings in VMWare player, and noticed that if I chose a specific resolution, I didn't get the blank screen. But - the resulting windows was too small.
Solution: ended up deleting all VM files other than .vmx and .vmdk. Booted and worked.
(Not sure what root cause was though.)