Ghostable vs. GhostableInLibrary – A Lesson on Custom Form Deployment in SharePoint


When provisioning files, you have the option to set files as either Ghostable, GhostableInLibrary, or, to not set that value, and keep it unghosted. All that means is can the file be cached at the web front end level, or, is it always served and built from the database. Ayman El-Hattab has a good write-up on this over at his blog here: http://www.sharepoint4arabs.com/AymanElHattab/Lists/Posts/Post.aspx?ID=97

However, what we want to know is how is the file treated during deployment for custom forms?

Let’s take for instance, you’ve created some custom list forms, and need to deploy those out to a site. Let’s call our file CustomForm1.aspx, and let’s tuck this away in a List Instance feature.

feature.xml

   1: <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
   2:          Id="{6A88A1A8-69A9-4bbb-8580-3FBA31B2DF66}"
   3:          Title="GhostableVsGhostableInLibrary"
   4:          Description="Ghostable vs. GhostableInLibrary Demonstration Code"
   5:          Scope="Web"
   6:          Hidden="false"
   7:          Version="1.0.0.0"
   8:          Creator="Grace-Hunt, LLC. | www.grace-hunt.com"
   9:          >
  10:   <ElementManifests>
  11:     <ElementManifest Location="manifest.xml"/>
  12:     <ElementFile Location="CustomForm1.aspx" />
  13:   </ElementManifests>
  14: </Feature>

manifest.xml

   1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   2:   <ListInstance FeatureId="{9749B227-36E3-4564-96FC-E75BA895BD74}" 
   3:                 Id="e7a36212-b396-4495-aaf9-be414fbd27df" 
   4:                 TemplateType="10306" 
   5:                 Title="CustomList" 
   6:                 Url="Lists/CustomList" 
   7:                 OnQuickLaunch="TRUE" 
   8:                 Description="Ghostable Vs. GhostableInLibrary Test"/>
   9:   <Module Name="CustomForm" Url="Lists/CustomList/CustomForms">
  10:     <File Path="CustomForm1.aspx" Url="CustomForm1.aspx" Type="GhostableInLibrary"/>
  11:   </Module>
  12: </Elements>

Let’s deploy this as “GhostableInLibrary” first, and see what happens…

image

Look at that, we have a list created from a custom list definition, which is not inheriting from a Document Library, however, if we deploy the form to our list as GhostableInLibrary, we see that the list item count goes up by 1, and, if we view the list contents, there is nothing there. This is obviously not what we want to do!

Now if we re-deploy this as just Ghostable, the list item count stays the same, and we have no “ghost” item in our list, and our custom forms have been properly deployed.

manifest.xml

   1: <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   2:   <ListInstance FeatureId="{9749B227-36E3-4564-96FC-E75BA895BD74}"
   3:                 Id="e7a36212-b396-4495-aaf9-be414fbd27df"
   4:                 TemplateType="10306"
   5:                 Title="CustomList2"
   6:                 Url="Lists/CustomList2"
   7:                 OnQuickLaunch="TRUE"
   8:                 Description="Ghostable Vs. GhostableInLibrary Test"/>
   9:   <Module Name="CustomForm" Url="Lists/CustomList2/CustomForms">
  10:     <File Path="CustomForm1.aspx" Url="CustomForm1.aspx" Type="Ghostable"/>
  11:   </Module>
  12:  
  13: </Elements>

image

So, with that, I leave you with the lesson learned here – if you need to deploy custom forms to a regular SharePoint list, deploy them as Ghostable, not GhostableInLibrary, otherwise you end up with that “ghost” item in the list.

 

About these ads

About Geoff Varosky
Geoff Varosky is a Managing Consultant at Jornata (www.jornata.com), a Microsoft Gold Partner focusing on SharePoint, Office 365, mobile technologies, and custom development solutions. Geoff is focused on delivering high value solutions to his customers in SharePoint and Office 365. He has been architecting and developing web based applications for over 16 years, and has been working with SharePoint for the past 10 years. Geoff is an active member of the SharePoint community, President and Co-Founder of the Boston Area SharePoint Users Group (www.bostonsharepointug.org), co-organizer for SharePoint Saturday Boston and speaks regularly at SharePoint events and user groups.

2 Responses to Ghostable vs. GhostableInLibrary – A Lesson on Custom Form Deployment in SharePoint

  1. Tamar Mansherov says:

    Very useful post.
    Thank you!

  2. creamcode says:

    nice I was looking for an example. Now its even more clear.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 3,290 other followers

%d bloggers like this: