Tuesday, January 18, 2011

Finding references to Content Types

This SQL script can be used to tell you where a content type is used. This is useful if you want to get rid of a stray content type created by InfoPath or workflow tools.

(Reposted from here)

DECLARE @ContentTypeName nvarchar(128)
SET @ContentTypeName='PC Review Task'

w.Title AS [Web Site],
w.FullUrl AS [Web Url],
al.tp_Title AS [List Title],
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

Sunday, January 2, 2011

InfoPath Tips and Tricks


  • Manual check-out and check-in is necessary. The InfoPath Designer lacks a source code control plug-in.

  • Create a folder "_Published" below the folder containing your InfoPath form. Check the folder into TFS, but do not check any contents.

  • Create a folder called "Code" below the folder containing the InfoPath form. Check all folder contents in.

Source Code

  • Be sure to reset the code location (on Form Options) to point to the Code folder described above. The default location is in the "My Documents" folder, which is useless for source code control.
  • Each time you work on a new InfoPath form, it will be necessary to reset the code location folder. (This option is retained in InfoPath, not the template.)


  • Set the publish location folder to "_Published" folder created above. Do not check the published file into TFS.
  • Reset the publish location every time you work on a different InfoPath form.
  • Generally speaking, publish all forms for "Administrator Approval"
  • Don't let InfoPath create content types for you. Do that ahead of time.
  • Be sure to check the "Allow users to edit data in this field using a datasheet or property page" for all promoted properties. This will allow the workflow to easily change them.

If you're wondering why all the rules, most of the issues are due to to things:

  1. InfoPath Designer is unaware of source code control.
  2. InfoPath Designer seems to have been designed with the idea in mind that a developer only works on one form at a time.
  3. InfoPath can make a mess of your SharePoint content types.