Posts

Showing posts from April, 2009

MOSS 2007 - Create List Item using aspx query string

Can’t get email enabled document libraries working? I was unable to get email enabled libraries to work in my SharePoint environment due to security issues relating to Active Directory account creation. The following code takes the query string parameters and creates a list item with the metadata in the specified list. I have this script being called by event handlers in Outlook, which call the page / script, passing the required details in the query string. By default, SharePoint (MOSS 2007) has code block enabled. This means that a page or script won’t load / run if there it contains code. To disable code blocks in MOSS, please see my post Code Blocks in MOSS 2007 for instructions on how to disable code blocks. The following code must be placed inside the aspx page the you would like to create the list items via the query string: <script type="text/c#" runat="server"> /*--------------------------------------------------------------------- This page/script i...

InfoPath data connection not returning all results from a SharePoint list

Problem I have a data connection retrieving ID values from a library’s items to determine the maximum ID of items currently in the list. Certain metadata results in items not appearing in the default view. When InfoPath queries the data connection, only IDs of items which display in the default view are retrieved. This became a problem as the maximum ID found by InfoPath was 240, when documents existed in the library with an ID of 246. To complicate the matter even further, a number of documents had been added and removed from the library making the next available ID 268. I needed InfoPath data connection to give me the maximum ID of current documents (246). Cause Data connections in InfoPath return the same results as the default view for the specified SharePoint list. Solution 1: Create a view which returns all items in a list / library (no filter criteria) – Set this view as default Will work well for lists libraries with less than 2000 items, and when a custom view is not ...

Code Blocks in MOSS 2007

By default, code blocks are set in the web.config file for the SharePoint server. For the code in this page to run, you will need to add an exception to the file to allow code to be run in the aspx. Security Warning: The web.config file accepts a wildcard character: * when specifying the path, which could allow any page in the specified site collection to run code. With code blocks disabled, it is possible to bypass or work around permissions used on sites, lists and libraries. The web.config file is generally located in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\CONFIG directory 1. Find the following tag in the web.config file: <pageparserpaths> ........ </pageparserpaths> 2. Add a <pageparserpath> tag with path required attributes (see below) <pageparserpath virtualpath="/_catalogs/masterpage/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true"> The above lin...

Split List View web part labels (javascript)

The following is a javascript function created to split long questions / column titles on a SharePoint survey or list when editing ( EditForm.aspx / DispForm.aspx ). I had a survey with questions containing hundreds of characters. When the EditForm.aspx / DispForm.aspx pages render the survey for completion, the questions are wrapped in < nobr > tags, which results in the page's width being much larger than the browser, regardless of resolution. The function takes all < nobr > elements and replaces those which match required criteria. Each question / column in the survey starts with a number, which is followed by the question ( "1. ..." "2. ..." etc.). The function runs through a series of tests to determine the currrent question. If the beginning of the line matches the required question number, contents of the element is replaced to include a break ( < br >) tag to split the line. Possible improvements: Split the question string after a s...