Wednesday, November 3, 2010

Missing Set Up Groups page in SharePoint 2010

I discovered today that SharePoint 2010 gives you a nice new way to set the associated members group, but in doing so has hidden the "Set up Groups for this Site" page after initial site creation.

First the members group: This experience is actually much better. Most end users I have talked to are only concerned with which group is the default selection in the "Add users to a SharePoint group" dropdown on the "Add Users" page. A lot of them had trouble with the complexity of having to go to the "set up groups" page for this as it is definitely not the intuitive place to go. SharePoint 2010 has made this much easier. You simply navigate to the group you want as default and select Settings->Make Default Group.

For some reason though, the SharePoint team decided that the addition of this option would allow them to hide the "Set up Groups for this Site" page. You are shown it when you first create a site (if you select unique permissions) but seemingly can't go back after the fact. This can be a problem when you need to discover which group is the associated owners group or change it to a different group.

Luckily you can still get to this page by url: /_layouts/permsetup.aspx

Thursday, February 18, 2010

Adding items to Large Lists

So I had this blog up before, but I did some digging with a friend at Microsoft and it turns out the additemoptimized method before really wasn't optimized at all... Here is new code that really is optimized...

When you access the List.Items property in the SharePoint API (say to add a new item to a list: List.Items.Add()) this get method runs (thanks Reflector!):


public virtual SPListItemCollection Items
{
get
{
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"Recursive\"";
return this.GetItems(query);
}
}


That actually makes sense if you were looking for the entire SPListItemCollection for the list, but doesn't make sense if you just want to add a new item (Why query ALL items in the list if you are just adding a new one??). Additionally, this becomes a problem when you are working with Very Large Lists as this query can be SLOW and possibly lock the table.

The alternative is to write your own query to get a much smaller SPListItemCollection for the list (I wanted a helper method to give me the collection so I can call Add() on it with different params, this one will only return the schema and not pull any items):


public static SPListItemCollection AddItemOptimized(SPList list)
{
SPQuery EmptyQuery = new SPQuery();
EmptyQuery.Query = "<Where><Eq><FieldRef Name='ID'/><Value Type='Number'>0</Value></Eq></Where>";
return list.GetItems(EmptyQuery);
}


And there you go, your query now returns your SPListItemCollection ready for .Add() without querying for any items!

Wednesday, June 3, 2009

How to test your workflow emails on a VM

I don't really want to install a mail server on my VM just to be able to test the emails that my Workflows generate. Instead you can do this in your web.config:

<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\IncomingEmails\" />
</smtp>
</mailSettings>
</system.net>



ref: http://msdn.microsoft.com/en-us/library/ms164241.aspx

Tuesday, June 2, 2009

That assembly does not allow partially trusted callers.

So I ran into something to be aware of today. We have a couple of Custom Field Types that we have written. As with all SharePoint CFTs, their assemblies are deployed to the GAC.

Today I was writing a Control (a Web Part would apply here just the same) that is deployed to the Bin. While deploying it I kept getting the annoying error: "That assembly does not allow partially trusted callers". I had my CAS policies defined and had the '[assembly: System.Security.AllowPartiallyTrustedCallers]' attribute in my AssemblyInfo.cs but I realized that I was getting the exception when I was trying to access the field value of an item that contained my Custom Field Type column (item["my CFT"])!

This was a good reminder that all CFTs should have the [assembly: System.Security.AllowPartiallyTrustedCallers] attribute, just in case, since you never know when a Web Part or some other partially trusted code will need to access them in the future.

Friday, May 15, 2009

Office 2003 datasheet view behavior

So for those of you out there still dealing with Office 2003 here in an annoyance that I found:

If you have a list with folders, and you go into one of the folders and try to create some items in DataSheet view, as soon as you create a row it will seem to disappear! What happens is that it actually gets created at the root level of the list! If you have Office 2007 the item gets successfully created inside the folder. The only way to get items into folders with 03 is to use the NewItem form but this can be a huge pain if you are trying to create 200 items at once.

Apparently this isn't something that is going to get fixed, it has to do with the fact that Office 2003 was designed to work with WSS 2.0 which did not allow you to create folders in Lists. Oh well, now at least you have been warned.

Friday, May 8, 2009

More DataForm WebPart goodies

Here is another handy control for use in data form web parts:

<td class="ms-toolbar" nowrap="">
<SharePoint:FormToolBar runat="server" ControlMode="New"/>
</td>


(Added the td class so it looks right)

This renders the normal listform toolbar (since if you just do Data View->Insert Data View, you don't get it).

Friday, May 1, 2009

DataSource CAML Keywords

So recently I needed to display the newest item added to a Very Large List via a dataform web part. The performance on SPQuery is pretty good as long as you return less than 2000 rows from your query. This means that you can't just return all of the list items from the datasource and then sort for the newest one. Instead I used some CAML keywords to help out. My DataSource query filtered on:

<Eq><FieldRef Name="Author" /><Value Type="Integer"><UserID /></Value></Eq>

and

<Eq><FieldRef Name="Created"/><Value Type="DateTime"><Today/></Value></Eq>

These two CAML rendering elements (for the current date, and current users ID). Helped the query return a very small number of rows, which could then be sorted by created date to show the newest.