65635

SharePoint - Invalid Field Name Error

Question:

<strong>UPDATE</strong>

Worth noting that this is only happening when the site definition is called from SPWebApplication.Sites.Add, if I use the UI then this works fine. My code is impersonating the system account when calling this code.

Am I right in thinking that the ApplyWebTemplate() method of SPSite is asynchronous? If this is the case then my issue is probably one of timing. I.e. the required infrastructure is not yet in place when this code is run.

<strong>ORIGINAL QUESTION</strong>

I have a custom site definition which is using an SPProvisioningProvider to configure the site collection.

After calling ApplyWebTemplate("BLANKINTERNET#0") to apply the standard publishing portal site defintion, I am trying to create a new page based on the welcome page with TOC page layout.

However I am getting an exception when I call this piece of code

Dim pubSite As New PublishingSite(_siteColl) Dim pubWeb As PublishingWeb = PublishingWeb.GetPublishingWeb(site) Dim layouts() As PageLayout = Nothing layouts = pubWeb.GetAvailablePageLayouts(_welcomeContentTypeID)

The following exception is raised at the GetAvailablePageLayouts method call.

Invalid field name. {7581e709-5d87-42e7-9fe6-698ef5e86dd3}

This is only happening on our live farm. It did not happen on dev or in the test environment so I am hoping it is a configuration change, but all references I can find on Tinterweb (sic) are related to the Field Type 'PublishingHidden' being missing, but how can I restore this given that this is happening in the site collection provisioning process?

Thanks

Charlie

Answer1:

are all required features (publishing infrastructure etc.) activated before performing this action? use something like the following:

// Check if the 'Publishing Prerequisites' feature is at the web and activated var pubprereqguid = new Guid("A392DA98-270B-4e85-9769-04C0FDE267AA"); if (site.Features[pubprereqguid] == null) { site.Features.Add(pubprereqguid); } // Check if the 'Publishing Resources' feature is at the web and activated var pubresguid = new Guid("AEBC918D-B20F-4a11-A1DB-9ED84D79C87E"); if (site.Features[pubresguid] == null) { site.Features.Add(pubresguid); }

Answer2:

You might want to check your code and make sure you are not accessing the field by its display name...

fieldName = web.lists[mylist].Fields["FieldName"].InternalName

Recommend

  • How does content in an a-element affects semantics, screen readers and search engines?
  • How do I create some kind of table of content in GitHub wiki?
  • Printing ggplots out of list does not work in knitr with rmarkdown
  • YouTube embed showinfo has been deprecated
  • PInvoke Nikon c++ DLL Function from c#
  • How can use the webRTC Javascript API to access the outgoing audio RTP timestamp at the sender and t
  • jquery globalcss IE opacity
  • Android video crop using ffmpeg
  • Visual Studio Publish - Include folder that is not added to Project
  • Cannot access sitecore item field via API
  • How to enumerate Azure subscriptions and tenants programmatically?
  • What is the difference between NetSuitePortType and NetSuiteService?
  • ReactJs.net server side render failing after publish
  • SIP Makefile fail (gnuwin and mingw)
  • How to generate an asynchronous reset verilog always blocks with chisel
  • How can I add web content type in liferay 6?
  • Command line installation of Code Signing certificates, .p12 files, and mobileprovisions
  • SIP API media codecs
  • Configure Spring's MappingJacksonHttpMessageConverter
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • WPF version of .ScaleControl?
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • How do I configure context broker accept post requests from my remote sensor?
  • Use of this Javascript
  • C++ Partial template specialization - design simplification
  • swift auto completion not working in Xcode6-Beta
  • htaccess rewriting URLs with multiple forward slashes
  • Importing jscolor library in angular 2
  • Display Images one by one with next and previous functionality
  • Web-crawler for facebook in python
  • How to get next/previous record number?
  • align graphs with different xlab
  • Comma separated Values
  • A cron job substitute?
  • Python: how to group similar lists together in a list of lists?
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize