Tuesday, July 20, 2010

Linked Data Ssource Limitation SP2010

Interesting SharePoint 2010 limitation, when using linked data sources ensure that your page does not display over 225 cells per page.

What I mean by Cells is the calculated value of rows by columns.

Unfortunately for whatever reason MOSS (SharePoint 2007) had the capability of going higher than 225 cells without failing but they did not keep the same capability in 2010.

The primary symptom of the error besides the Data View Web Part not rendering is that you end up with a StackOverflowException in the logs. Search the correlation ID you receive in the error in the logs and you will find the corresponding error.

Reducing the page size or displayed columns is really the only non-code fix and is the short term solution I was forced to implement.

The MS rep I discussed this with said the defect is due to the SharePoint Designer render, and recommended a long term solution which will be to implement the page in the sandbox environment using custom built pages with the client object model. He indicated MS may eventually fix the issue.


Bug characterization Information
  • Removing the second template call replaced with spaces did not lead to an error.
    This means I still had 375 cells but only 125 contained data from a list the other 250 were just html spaces.
  • Tried encapsulating the template call in a variable to see if it would force better memory optimization, this did not change anything.
  • This issue seems to only effect joined lists as I have a single list in a Data Form Web Part that is displaying 5 columns by about ~200 rows
  • Always fails at 375 cells

Wednesday, June 30, 2010

Using the Row ID value in a calculated column

Row ID cannot be referenced directly in a calculated column. Well that’s not exactly true. You can do it once and the values will stay after the calculated column has been defined, meaning you just put [ID] in the field. But once an Item is added to the list or a record is edited it will no longer have the right reference in the field, it loses the brackets around ID.

Summary of MS reference doc on this issue:
http://office.microsoft.com/en-us/windows-sharepoint-services-help/introduction-to-data-calculations-HA010121588.aspx
- You cannot reference the ID of a row for a newly inserted row. The ID does not yet exist when the calculation is performed.
- You cannot reference another column in a formula that creates a default value for a column.
- This is also valid for other system columns like [Version] or [Modified].
- Applies to SharePoint 2007 and 2010

There are two ways to address the problem.

Short term / non-permanent: The calculated filed can be reset after any adds or edits by adding the brackets around the ID reference, so ID will look like [ID] again.

Long term / permanent:
1. Create a number column w/ 0 deciaml places (Via web portal)
     a. I usually call it LookupID
     b. Create a calculated column that references the LookupID column (E.g. =[LookupID])
          i. Or replace the reference of ID with LookupID for an existing calculated column
2. For lists with existing records
     a. Create a special data sheet view that has ID and LookupID in it. (Via web portal)
     b. Copy ID value to LookupID
3. Now Create a workflow that populates the LookupID column with the actual row ID for new records (Via SharePoint designer)
     a. Set the step action to be “Set Field in current Item”
     b. Select LookupID as the Field
     c. For Value use define workflow value button
          i. Leave Current Item as DataSource
          ii. Select ID as Field from Source
     d. Set LookupID to CurrentItem:ID

Thursday, June 17, 2010

Hiding and Unhiding Lists and Libraries in SP2010

In SharePoint designer you gain the ability to hide lists. This provides some obscurity capability in that unless the users know list name they most likely won’t be able to find the list. This does not mean that the lists are secure, security by obscurity has been proven to fail every time.

How to hide a list:
First Hiding only takes 2 button clicks.

Using SharePoint Designer open the property page of the List and in the settings area check “Hide from browser” then save.

The list will now be hidden.
Though this does not prevent direct linking to the list if for example the user knows the name of the list or has a URL to it. This can be leveraged by having direct links that one can use to access the list directly after the list is hidden.

Working with Hidden lists
Once a list is hidden it is hidden from not only the browser it is also hidden from SharePoint designer.
Note I personally think that having the list hidden from SharePoint designer is a bug and have filled a report with Microsoft.

If you need to work with it and you do not have the information to work with the list saved elsewhere (Meaning the list Query information) you will need to unhide it.

Unhiding a list
1. Using SharePoint Designer
2. Select All Files in the Site Objects area in Navigation
3. Select List folder
4. *Important* Right Click to bring up the context menu (Left clicking will bring up the list views)
5. Select Properties from the Context menu
6. Deselect Hide from browser
7. Save Changes (The List will now be viewable via all site content in the browser and in the List and Libraries Site Object in SharePoint Designer)

Thursday, May 27, 2010

Posting code in Blogger

Ok Blogger gets a big Fail for support of writing and sharing code via a blog. Luckily there seems to be a solution, a text area tag.

I first found a solution over at dreamincode.net - http://www.dreamincode.net/forums/topic/61131-code-in-bloggercom-posts/
Though this one had formatting issues.

Then I came across this entry which talks a bout a code tag and was much happier with the formatting that I was able to do.
http://jayaprakashkv.blogspot.com/2007/12/how-to-add-html-code-in-blogger-post.html


It links to this very nifty tool here - http://www.simplebits.com/cgi-bin/simplecode.pl



Though that tool was not the final solution I actually had to go back in and add the nbsp operator to get indenting to look right but I had the right look finally.

Wednesday, May 26, 2010

jQuery UI (Tabs) on SharePoint

There have been several articles written about using jQuery on SharePoint.

This article focuses specifically on implementing jQuery UI Tabs in a SharePoint Master Page using SharePoint Designer.

So what exactly is jQuery UI Tabs, it is a JavaScript that formats div panels to function as a tab control. See the demo page here for the script in action: http://jqueryui.com/demos/tabs/

Walkthrough

Requirements
A master page with a Content Place Holder in the header and another one in the body tag.
Most master pages will have this by default.
The jQuery UI libraries - http://jqueryui.com/
I recommend on just downloading the default Theme and with all of the UI features selected to start with. You can always down load a different theme latter once the functionality is working as expected.

You will also need the cookie library if you are going to use that functionality - http://plugins.jquery.com/project/cookie
This example includes the use of the cookie Library.


Instructions
1. Create a new page from master
2. Add the libraries to the head tag

In my master page the content place holder is called PlaceHolderAdditionalPageHead so I needed to locate that in the code view of my page.

Then I add the references to the theme, the main jQuery library, the jQuery UI library, and the cookie library.

So my place holder now looks like this

<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderAdditionalPageHead">
  <link type="text/css" href="css/cupertino/jquery-ui-1.8rc1.custom.css" rel="Stylesheet" />
  <script type="text/javascript" SRC="scripts/jquery-1.4.2.min.js" ></ script >
  <script type="text/javascript" src="scripts/jquery-ui-1.8rc3.custom.min.js"></script>
  <script type="text/javascript" src="scripts/jquery_cookie.js"></script>
</asp:Content>


3. Add the script that to change how the div panels render

<!--init tabs-->
<!--Tab selection expires in one day (24hrs)-->
<script type="text/javascript">
  $(document).ready(function() {
  $("#tabContainer ").tabs({ cookie: { expires: 1 } });
 });
</script>


4. Last add the div panels which will hold the content
a. The li tags will be your tab headers
b. The corresponding div panels will hold your tab content

<div id=tabContainer style="width: 100%">
  <ul>
  <li><a href="#tab-1">tab1</a></li>
  <li><a href="#tab-2">tab2</a></li>
  <li><a href="#tab-3">tab3</a></li>
  <li><a href="#tab-4">tab4</a></li>
  <li><a href="#tab-5">tab5</a></li>
  </ul>
 <div id=tab-1 style="width: 100%">Insert tab1 content here</div>
 <div id=tab-2 style="width: 100%">Insert tab2 content here </div>
 <div id=tab-3 style="width: 100%">Insert tab3 content here </div>
 <div id=tab-4 style="width: 100%">Insert tab4 content here </div>
 <div id=tab-5 style="width: 100%">Insert tab5 content here </div>
</div>


Wrap-up
The great thing about this is it works in both SharePoint 2007 and 2010 and its completely rendered client side. Now for those that run w/ JavaScript disabled it degrades gracefully as well, stacking the div panel on top of each other.

There are no restrictions on the div panel content; it can be anything that is allowed in a standard div, Data View Web Parts to strait HTML for example.

Happy Tabbing! :)

Wednesday, May 5, 2010

SharePoint 2010 - Redirecting a form

In MOSS the most efficient and reliable method of redirecting a form was to use a query string parameter. This is where you have the page url followed by a parameter. Site.com\page.aspx?source=targetURL for example.

In 2010 Microsoft has made a vast improvement where specifying the redirect URL in the custom form actually works. What is great about this is it allows for a page to go to two different locations based off wither the user hits save or cancel.

To implement find the onclick command for the button whose behavior you would like to change. It should be calling a GenFireServerEvent in the ddwrt namespace. Append ‘;__redirect={targetURL}’ following the commit or cancel filed. The field should now look like this
__commit;__redirect={ targetURL }

Save the page and you have a fully functioning redirect hidden from the users.

Many thanks to IOTAP for the pointer - http://web.iotap.com/Blogs/tabid/277/EntryId/7/Redirecting-to-a-custom-URL-from-Sharepoint-custom-forms.aspx

Saturday, April 24, 2010

Web Site Performance improvements

I updated the site so that it performs better by adjusting the caching behavior and limiting the number of blog articles I pull for the front page.