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)