Saturday, December 22, 2007
Google Maps and SharePoint
This blog describe how to inline a simple Google Map in SharePoint. Check out this link for documentation.
If you wish to learn more don't hesitate to contact me.
Saturday, December 01, 2007
Content By Type Web Part
Sunday, November 18, 2007
Large content databases - added indexes for performance improvements
As only a few properties are contained in indexes searches will most likely lead to table-scans. Having a few 1.000 documents in SharePoint might not lead to slow performance but if you're looking at 100.000+ documents the situation is obviously different as outlined in this excellent article.
Thursday, November 08, 2007
Potentially excessive number of SPRequest objects currently unreleased on thread
In order to avoid the problem in your code ensure to properly dispose the SPWeb object as outlined in this Microsoft article as well as in this blog. One important thing missing is the SPWeb.Webs() object - if using this object you also need to dispose all webs within the collection.
Potential reasons include:
- Invalid XSL stylesheet
- Drop down lists - simple C# example
- Orphans
Friday, November 02, 2007
SharePoint Content Database
Where is my content type used
DECLARE @ContentTypeName nvarchar(128)
SET @ContentTypeName='Document'
SELECT w.Title AS [Web Site], w.FullUrl AS [Web Url], al.tp_Title AS [List Title], ct2.* FROM ContentTypes ct1 JOIN ContentTypes ct2 ON LEFT(ct2.ContentTypeId, Len(ct1.ContentTypeId))=ct1.ContentTypeId LEFT OUTER JOIN dbo.ContentTypeUsage ctu ON LEFT(ctu.ContentTypeId, Len(ct2.ContentTypeId)) = ct2.ContentTypeId LEFT OUTER JOIN dbo.AllLists al ON ctu.ListId = al.tp_Id AND ctu.WebId=al.tp_WebId LEFT OUTER JOIN dbo.Webs w ON al.tp_WebId = w.Id WHERE ct1.ResourceDir=@ContentTypeName
Monday, October 22, 2007
SharePoint AJAX Toolkit
Sunday, October 21, 2007
AJAX on SharePoint - how to get started
Friday, September 28, 2007
Web Content Management Content Type IDs
Saturday, September 08, 2007
ASP.NET or SharePoint --> and SharePoint
Tuesday, August 21, 2007
SPFileCollection.Add ignores title property on upload
Adding system properties doesn't work:
dim oHash as new hashtable
oHash.add("DocumentType","Contract")
oHash.add("Title","Leasing agreement with Smart Leasing Inc.")
oFile = oFolder.Files.Add(
oFile.Item("Title") is not equal to "Leasing agreement...".
The only way is to modify it manually after having added the file, e.g.
dim li as SPListItem
li = oFile.Item
li("Title")="Leasing agreement..."
li.UpdateOverwriteVersion(); ' In order to avoid creating a new version
Any explanations why "Title" property cannot be set in oHash would be appreciated.
Other problems with Add has been reported various places. This blog is worth reading.
Wednesday, August 08, 2007
SharePoint explorer view - cut-paste issues
However, in a few situations the "explorer view" behaves quite strange.
If you try using Cut-Paste the file is moved from one place to another - including all the history, old versions etc. This is great. However - the Cut-Paste does not respect event handlers that are operational.
I have an ItemDeleting events that blocks deleting documents from certain document libraries. It works fine from all interfaces (Word, SharePoint, Web Dav) - except from cut-paste. Obviously Microsoft had to implement custom code to handle the clipboard in this situation - and it seems that they forgot to respect the event handlers. Just too bad.
Any experience with similar issues much appreciated - as well as workarounds.
Saturday, July 28, 2007
Wednesday, July 25, 2007
Great workflow tutorial - expense reporting
Wednesday, July 18, 2007
Friday, July 13, 2007
Monday, July 09, 2007
Managing Active Directory - SharePoint
Extending Active Directory with custom schemas is an excellent model for applications that can act as an LDAP client (e.q. Exformatics ESDH). This allows custom application attributes to be stored in Active Directory, thus maintaining one single point of administration for Users and Computers in organisations.
One of the challenges is that the standard Windows Users, Groups and Computers view doesn't allow for management of custom attributes. ADSI Edit is the answer. Read more here.
Friday, June 29, 2007
Exception (0x81071003): Unable to update the information in the Microsoft Office document
The exception occur in a ItemAdded event handler where I add a global unique human-readable document id to the document.
This most likely due to an error in the property promotion/demotion part of SharePoint.
If I try to open up the Excel sheet myself I get an error as inline VBA code cannot be executed. So if SharePoint tries the same no wonder it doesn't work. But how can you block promotion/demotion in such situations.
Ideas very much appreciated.
Monday, June 11, 2007
Search Query Web Service Test Tool for Microsoft Office SharePoint Server (MOSS) 2007
Tuesday, June 05, 2007
Office property promotion/demotion in SharePoint
Wednesday, May 09, 2007
SharePoint fine grained permission control
Wednesday, May 02, 2007
Approve a SPFolder programmatically
Conclusion: And it's just sooo simple --> check out this.
Luckily it seems that you can programmatically change the _ModerationStatus of a folder item using the ProcessBatchData operation of the SPWeb object as outlined in this blog.
Unfortunately for me I can't get it working - yet. My code for ProcessBatchData looks like this:
<?xml version="1.0" encoding="UTF-8"?><ows:Batch OnError="Continue" >
<SetList Scope="Request">{5234ebfe-58c5-4af3-8879-cde8ade42315}</SetList>
<SetVar Name="DatesInGregorian">TRUE</SetVar>
<Method ID="1,Update">
<SetVar Name="Cmd">Save</SetVar>
<SetVar Name="ID">14</SetVar>
<SetVar Name="owshiddenversion">1</SetVar>
<SetVar Name="owsfileref">http://intranet/Projects/Labbooks/ABC</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#_ModerationStatus">0</SetVar>
<SetVar Name="urn:schemas-microsoft-com:office:office#_ModerationComments">Exformatics Approved Folder</SetVar>
</Method>
</ows:Batch>
I get a proper reply back - but the folder is not yet approved. Maybe it only works in SharePoint 2003 and not in MOSS 2007. However, according to Joris Poelmans ProcessBatchData also works for MOSS 2007 - at least for creating new pages.
A good description with similar syntax can be found here - but not working either :-(
Wednesday, April 25, 2007
Strange workflow error - visual studio - Error 319 (0x13F)
Error 4 Property 'WorkflowProperties' has invalid value. Field type 'Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties' does not match with the expected type 'Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties'.
Any hints, ideas etc?
Workflow error codes can be found on MSDN, but little information about how to fix them.
I also get the error as outlined below:
Could not bind property 'WorkflowProperties'
Could not load file or assembly 'Microsoft.SharePoint.Library, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
I'm also trying to update VS.Net 2005 with "Windows Workflow Foundation Extensions for Visual Studio 2005" as outlined in various guidelines. However, it seems that Microsoft has renamed the tool - at least I cannot find the latest released on MSDN. I often wonder why it has to be soooooooo difficult.
Saturday, April 21, 2007
Reorder properties in Document Libraries
Sunday, April 15, 2007
Controlling MOSS Document templates
Ton Stegeman has written an excellent blot about how to control MOSS document templates programmatically. Thanks you.
Monday, April 02, 2007
SPFieldUser with default value
Monday, March 26, 2007
SPItemEventReceiver - ItemAdded and ItemUpdated runs simultaneous
It appears that is it critical to use SystemUpdate(...) rather than Update() as outlined here. But a note claims this was only an issue for beta versions?
I have tried using SystemUpdate rather than Update as sketched below, read this blog.
this.DisableEventFiring();
anItem.SystemUpdate(false);
this.EnableEventFiring();
The sequence of events is also quite strange as outlined in many blogs, try reading this.
Solution: It seems that if you ensure using SystemUpdate and Disable/Enable EventFiring as sketched above consistently in your eventhandler you don't have any issues. But I'm not yet convinced.
Friday, March 23, 2007
InfoPath password field
A workaround, using a custom task pane is outlined here. Unfortuntale that will not work with MOSS workflows :-(
A custom ActiveX component might be the only solution - quite difficult to manage and setup. But it is possible to create the control is Visual Basic 6.0 as outlined here.
Other ideas very much appreciated.
It seems that I could use Visual Studio Tools for Applications (VSTA). Will elaborate more shortly...
Thursday, March 22, 2007
Custom columns not visible
Saturday, March 17, 2007
SPWebEventReceiver - SiteDeleting
So far I have not been able to get it working - but hopefully shortly.
Ideas and input very much appreciated.
I found a good example here.
Sunday, March 11, 2007
A duplicate name "_dlc_Exempt" was found.
Happens when I try to execute:
Microsoft.Office.RecordsManagement.InformationPolicy.Policy.CreatePolicy(SPContentType ct, Policy globalPolicy)
Conclusion: Believe it or not - simply ignore this error!!! The policy is created despite the exception - so catch the exception - and then continue. Excellent API.
Computed columns cannot be added to Document library
Friday, March 09, 2007
Custom Link field in a SharePoint Document Library
Depending on the version of the file I also wish to display different fields. I would like the published version of the file to be accessed from the same link always - and if a minor version exists this version should be accessed from another link in the list.
I have tried to create a feature with a custom field that contains exactly this stuff - no luck. The new custom field simply doesn't show up in my view.
I came across this blog but I couldn't get it working :-( Couldn't add an IF statement in a computed field. I got the error "The formula contains a syntax error or is not supported. " when I tried to add the IF statement. As a next step I studied the difference between Computed and Calculated fields as outlined in this blog. When I add the field as a Calculated field the above blog works - voila. However, changing fldtypes.xml is not recommended - would like to get it working using standard features. The other issue is that I would need to add this calculated field to all my document types in order to enable field selection on a view.
The issue currently is the fact that computed fields cannot easily be added to list or views - at least they don't show up if added as features. Calculated fields does.
Remember the difference between the two field types: Computed fields are not stored in the database but calculated fields are.
Further - you need to note the difference between columns, fields and properties - as described in this blog.
Still not fully understanding what is going on it seems that calculated fields are not really columns - so they cannot be viewed in the Site Columns collection (despite the fact they are added with other fields as part of the same feature). Neither - unfortunately - they cannot be added to a view.
If I look into the SPWeb object
.AvailableSiteColumns('
my column is returned. But how can I add it to the view?
Apparently other people have had this issue too - here and here.
In SharePoint 2003 I simply modified onet.xml to accomodate this new field, as outlined here.
Sunday, March 04, 2007
Modify SharePoint Content type order programmatically
While the code fixes the layout for the New button it unfortunately doesn't solves the issue for Upload, as Upload uses the default content type for the document library - not for the folder :-(
Any ideas much appreciated
Thursday, March 01, 2007
InformationPolicy - content types - challenges
However - there is a challenge that I have not yet managed to overcome. When associating the informatonpolicy with a content type within a document library it works just fine.
But when I create a site content type and then create a new document library and add the site content type (with the information policy associated) to the document library nothing works :-(
When inspecting the details it turns out that no event receivers are associated with the content type found on the document library.
I was assuming that once an information policy is associated it would be enforced in all locations. This assumption is not correct.
Tuesday, February 27, 2007
Wednesday, February 21, 2007
Delete a contenttype from a document library
From the administration UI you can remove a contenttype by selecting "Delete this content type" as outlined here:
But how do you do it programmatically?`
If you take a look at SPDocumentLibrary it has a reference to ContentTypes. The collection has a delete operation which takes a GUID of the content type as parameter, as outlined by Microsoft here.
dim oDocLib as SPDocumentLibrary
dim oCT as SPContentType
oCT = oDocLib.ContentTypes("Documents")
oDocLib.ContentTypes.Delete(oCT.Id)
Trying out this code raises an exception:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: id
at Microsoft.SharePoint.SPContentTypeCollection.Delete(SPContentTypeId id)
Inputs very much appreciated.
I got the idea to try using the Lists.asmx web service as described here by Microsoft. No luck so far.
You can get around the issue as described here. Set the content type programmatically before you add the items - but that is not really the answer long term :-(
Conclusion: Now it works!!!
I tried to delete the Documents content type found in the web collection AvailableContentType i.e. executing the code:
dim oWeb as SPWeb
dim oDocLib as SPDocumentLibrary
dim oCT as SPContentType
oCT = oWeb.AvailableContentTypes("Documents")
oDocLib.ContentTypes.Delete(oCT.Id)
this fails as described above.
The above code works.
Tuesday, February 20, 2007
Changing default content type in a Document Library
I have searched but couldn't find any information about how to modify the default content type and the sequence of content types in a document library. I found this blog saying it cannot be done.
Conclusion: It is possible - just read this blog.
Sunday, February 18, 2007
SPItemEventReceiver - Mapping end-user events to SharePoint events
- ItemAdding - i.e. adding a new item - ok
- ItemAdded - the new item has been added - ok
- ItemUpdating - updating an existing item
- ItemUpdated - an existing item has been updated
- ItemCheckingIn - about to checkin an item
- ItemCheckedIn - item checked in
- ItemCheckingOut - about to checkout an item
- ItemCheckedOut - item checked out
- ItemDeleting - about to delete an existing item
- ItemDeleted - an existing item is deleted
- ItemUncheckingOut -what does this really mean?
- ItemUncheckedOut - well
If you look at the SharePoint menu for an approved item it'll show the following menu items:
What puzzles me is the "Unpublish this version" menu item? Which event is linked with this operation?
When you check-in an item you can also choose to check-in and overwrite the existing version - thereby damaging the version control.
Conclusion: The ItemUpdating event is the answer! If you inspect the ModerationInformation field of the listitem you can find out the state - and block the Unpublish This Version event.
Saturday, February 17, 2007
List SPEventReceiver Before- and AfterProperties
I found this great posting which explains how.
Friday, February 16, 2007
Custom field type definition in SharePoint
Rather than reinventing the wheel I found this excellent post about the subject.
Tuesday, February 13, 2007
Replace MOSS 2007 built-in Approval Workflow
However, co-existing with SharePoint default content approval seems to be quite confusing - especially to end-users. Both approval workflows appears in the end-user interface as outlined below:
In the example above I have approved the content using the Sample Appoval Workflow from ECM. Notice that the status is Approved for Sample Approval Workflow - whereas it is still pending for the built-in approval workflow.
If approving using the built-in approval buttons the system will notify me during the approval with the following message:
resulting in the following screen:
Now my content has been approved by the built-in approval workflow - whereas it is cancelled in my custom workflow.
Ideas very much appreciated.
Monday, February 12, 2007
Filtering a view based on workflow status
Sunday, February 11, 2007
Replace MOSS 2007 built-in Approval Workflow
In some situations you might wish to replace this approval with you own custom workflow.
The tricky thing is how to accomplish this. While you can easily add new workflows to a list or a content type, I cannot figure out how the existing built-in workflow is replaced automatically.
The DefaultContentApprovalWorkflowId property seems to be solution - the only issue is that it doesn't work as the built-in workflow is not replaced.
Any ideas?
Thursday, February 08, 2007
Linking SPContentType with an Microsoft.Office.RecordsManagement.InformationPolicy
But how do you associate a content class with an Information Policy in code?
The Microsoft.Office.RecordsManagement.InformationPolicy object contains the Microsoft.Office.RecordsManagement.InformationPolicy.PolicyCatalog.FeatureList which is a PolicyFeatureCollection of all available PolicyFeatures installed.
It contains the following features:
- Barcode
- Label
- Expiration
- Audit
as well as my custom feature, RegulatoryDocumentManagement.
Linking a contenttype with an information policy is done through the CreatePolicy interface described at MSDN.
Monday, February 05, 2007
MOSS ItemAdded event - problem
I'm testing the DocIntegrityPolicy example found in ECM toolkit. It provides an example of implementing a custom information management policy. When new items are added to a document library, the ItemAdded event set the value of a certain property to a MH5 hash value of the file in order to ensure integrity of the file. So far so good.
Unfortunately, this behavior introduces a problem in SharePoint. Modifying the content during the upload process results in an error: "The file
Please also refer to this blog for a similar example.
The sequence of events is outlined below:
1. Pick the document for upload |
2. Enter document properties |
3. Error reported |
The good news is the the document is uploaded just fine - with all properties (including the ones added in ItemAdded) set as expected. But why the error?
To make things even more compliacated it turns out that the modification of the list itself during event registration (i.e. adding the new field to the list) raises another issue with the error: "The object has been updated by another user since it was last fetched".
Friday, February 02, 2007
Modifying barcodes in Word - uniqueness
My experience with SharePoint has proved this as we have had a solution for regulatory document management based on SharePoint since 2001.
However, in SharePoint 2007 things are not as easy as we expected. As an example SharePoint build in barcodes - which I have assumed to be unique - can easily be modified by the end-user as sketched below.
First - take a look at the SharePoint document library:
Then we open the file in Word, and access the properties. Note that the barcode value has been synchronized with a Word property - which can be edited manually as sketched below:
When I finish editing my Word document and return to SharePoint document library the barcode has been modified:
The result is fairly disappointing as uniqueness of barcodes cannot be guaranteed by SharePoint.
Thursday, February 01, 2007
MOSS calculated field cannot point to a hidden field
I define a calculated field that points to a hidden field that I have also defined. When I try to add the new field to a site I get the error: "One or more column references are not allowed, because the columns are defined as a data type that is not supported in formulas".
If I remove the
Hidden="TRUE"
from the Field definition in the feature it works just fine.
Any ideas? If I add the field initially with HIDDEN="FALSE" everything works just fine. Afterwards I can change HIDDEN=TRUE without any issues - except from the fact that I cannot use the end-user interface to add a content type with that field in to a document library. But doing it programmatically works just fine - if I remember to toggle hidden in the operation. Strange.
Refer to this news-posting for similar experience.
Wednesday, January 24, 2007
ItemAuditing - fine grained custom auditing for SharePoint 2007
If you wish to develop your own auditing, you can use Windows SharePoint Services 3.0 and the ItemAuditing example. First read the whitepaper and setup instructions - then download the code and try it out. This example is also part of SharePoint Enterprise Content Management (ECM) SDK.
Monday, January 15, 2007
Failed on Start - MOSS workflow
Wednesday, January 03, 2007
MOSS Barcodes not unique
To our disappointment it turns out that SharePoint 2007, MOSS, barcodes are not unique.
SharePoint does not guarantee uniqueness.
Did I miss something?
Check out this blog for information.