SharePoint allows you to publish SharePoint links so that they appear in Office ‘Save As’ dialog boxes. This is useful if you want to encourage users to save Word, Excel and other Office documents directly into SharePoint rather than the file system as this dialog is shown the first time you save a new file. It allows you to create targeted shortcuts so relevant document libraries and sites are easily accessible when saving Office documents.
In SharePoint 2010 these published links are managed under the user profile service application in a page called ‘Published links to Office client applications’.
We had an issue this week, however, where a client encountered the following error when trying to browse to this page.
The error message stated:
Your search encountered an error. If the problem persists, contact the portal site administrator.
There was nothing obvious in the event logs or the ULS logs about this message making it a bit of a mystery as to why it was failing.
After some investigation I found that the problem could be recreated by creating a published link that related to an audience and then deleting that audience. Yes that’s right, there is some really shoddy coding going on there and simply deleting the audience through the UI causes the entire published links screen to stop working! As you can’t see the links anymore you cannot delete the affected links. You also can’t undo the audience deletion so you are essentially stuck.
With some digging I found the values are stored in the SharedListSync table of the Profile DB relating to the user profile service application. As deleting information out of the SharePoint databases risks causing worse problems (not to mention leaving your farm in an unsupported state) I had a look at how the UI handles the deletion when the page is working and found a much better workaround.
If you add a checkbox to the page with a value that matches the ID of the link in the database you can delete the affected links. This is basically mimicking the checkboxes that would be on the page if it rendered correctly. You can then select the checkbox and use the delete button in exactly the same way SharePoint allows you to i.e. in a supported manner. This is shown below:
Note the highlighted checkbox that has been manually inserted into the DOM by editing the HTML mark up. The value=”1” will mean that the link with the ItemId of 1 in the database will be deleted. Determining the ID’s to delete does require access to the Profile DB but this can be done by taking a backup of the affected database and restoring it in a test environment if you don’t have access to live data. What you need to look for is the ItemId field in the SharedListSync table.
The values in the TargetTo column relate to an audience stored in the Profile_SearchAudienceTable. In this case we can see that the row with an ItemId of 2 has an audience so this would be the item to delete if there was a problem.
To add the checkbox to the page you can use tools such as Firebug for Firefox or the IE Developer toolbar. In either tool you just need to select the HTML tab, click edit and insert an input element with type=”checkbox” and a value matching the ItemId of the row to delete. For example to delete the row with ItemId of 2 you could insert the following.
You need to make sure the input element is within the FORM tag of the page but it doesn’t matter where you put it. For example the screen shot below shows how you can edit the HTML using the IE developer toolbar to add the tag directly after the opening FORM element. This will place the checkbox to delete the item at the very top of the page.
If you have multiple items to remove you can add in multiple input elements, select all the items and delete them at once. Once you have deleted the links with missing audiences the screen should return to a usable state.