Featured Post

SQL Query in SharePoint

The "FullTextSqlQuery" object's constructor requires an object that has context but don't be fooled. This context will no...

Thursday, January 17, 2013

Document.ReadOnly (Office 2007) does not consider checked in documents

If you have ever worked with word add-ins there will have been a point in time where you would have needed to determine whether a document is read only or not. There is a boolean property on the Document class called ReadOnly.

With the introduction of SharePoint documents can be read-only if they have not been checked out. Word 2010 takes this into account however Word 2007 can out before SharePoint and does not cater for this. If your document is not checked-out (making it read only), the ReadOnly property will return false in Word 2007.

The way we resolved this issue is by creating an method on our webservice which indicates whether a document is checked out or not. This helps us determine whether we can allow the user to edit the document. Remember that forcing check outs on documents in libraries is configurable so remember to check this setting first.


if (!spListItem.ForeCheckout)
{
   return false;
}


if (file.CheckOutType == SPFile.SPCheckOutType.None)
{
   return false;
}

return true;




No comments:

Post a Comment