Updating choice fields via SharePoint Web Services
**May 20, 2010 Update
** This post is about using a C# console app to update choice fields via SharePoint web services. If you are looking for more information on how SharePoint web services can be called via JavaScript, check out my post on building a simple SharePoint AJAX app.
My problem started with a simple change to a site column. I had originally created a Country field with the following values:
- US
- Canada
After a change in requirements, the new values for the field were:
- Canada
- Germany
- Great Britain
- Ireland
- United States
After updating the site column, I then needed to update the hundreds of items in the list to use “United States” instead of “US”. Instead of updating hundreds of items manually, I decided to write a small web services console app. (I was also not able to update it in datasheet… due to content approval maybe???)
However, I quickly ran into problems when attempting to update the multi-select choice field.
SharePoint's SPGridView, filtering, and apostrophes
May 20, 2010 Update
If you are looking for a great example on how to create an SPGridView, check out Erik Burger’s blog:
- Building A SPGridView Control – Part 1: Introducing the SPGridView
- Building A SPGridView Control – Part 2: Filtering
This post is really meant to supplement part 2 of Erik’s guide and address values in the grid that include apostrophes when using filtering.
The SPGridView is one of the most useful SharePoint controls. You can use it to do sorting, grouping, and filtering just like the out of the box List View Web Part does for regular lists and libraries. This makes it relatively easy to create a custom grid with your own data. Unfortunately, filtering with the SPGridView is a little quirky, especially if your data could potentially contain apostrophes.
Filtering a SharePoint list by Workflow Status
The most recent problem I ran into was when I tried to filter out items that had a certain Workflow status in the list. More specifically, I was trying to filter on items that had errored out and had a status of “Error Occurred” in the list.
Creating a SharePoint Alert with different EventTypes
I recently ran into a problem creating alerts in a web part for the current user. After the alert was added, no matter what I set the SPAlert’s EventType to, it always defaulted to All. I finally figured out a way around this problem thanks to a helpful post by erwin at sharepointology.
AutoIt3 script to auto resize windows
One thing that bugs me all the time is when a window doesn’t remember the position that it was resized or moved to. Although it is more of a nuisance than anything else, I decided to write a little AutoIt3 script to automatically resize my Remote Desktop windows to be the certain place and size that I prefer them to be in.
Boolean values in an Event Handler
While researching a bug with editing in datasheet view and a custom list event handler, I discovered strange behavior with boolean values. Any boolean value you get from the SPItemEventDataCollection depends on where the item was originally edited: either using the regular user interface (EditForm.aspx, NewForm.aspx) or using datasheet view.
Creating a link to the current item in a workflow
When creating a workflow using SharePoint Designer, oftentimes it is useful to be able to create a link to the current list item. Unfortunately, the built in columns are not so helpful.
Selected tab in the Top Link Bar
I recently ran into the weird issue of not having my tabs highlighted correctly. After consulting Uncle Google, it seems Andy Burns ran into this same issue.
The problem started after creating multiple aspx pages within my site and then setting up a tab for each page by editing the Top Link Bar (also known as the top navigation) under Site Settings. Each of the tabs worked correctly, but after clicking a tab that tab would not be highlighted and the home tab would stay selected.
The Danger in using SPSite.OpenWeb()
Recently I ran into a “feature” of SharePoint’s SPSite.OpenWeb() method (the no argument constructor specifically). If the OpenWeb() method is used with a URL that is not known to exist, it can result in some unexpected behavior.
Make a Text field read only on EditForm.aspx without SPD
November 10, 2010 Update: I’ve posted the sequel to this post: Autopopulate a SharePoint Form from URL (with SPUtility.js). The code below will not work in SharePoint 2013 so you should use SPUtility.js!
After looking at a couple of examples online, most of them require the use of SharePoint Designer to make a field read only (or to hide it). Here is a method to make a field readonly using only Prototype (javascript library) and a Content Editor Web Part