October 30, 2013

Solution of the issue “field type is not installed properly. go to the list settings page to delete this field”

Problem :- “field type is not installed properly. go to the list settings page to delete this field”
Solution
Problem :- “field type is not installed properly. go to the list settings page to delete this field”
Solution
1.   Log In in SQL Server
2.   Select your appropriate database
3.   Go to query window and run following query.it will display all record which field have blank type.

   1:  Select Definition,* from dbo.ContentTypes where ISNULL(Definition,'0')<>'0' 
   2:   and Definition like '<Field Type=""%'
4.   Now run following query in your query window.it will delete all the site columns which field type is blank.

   1:  delete from dbo.ContentTypes where ISNULL(Definition,'0')<>'0' 
   2:   and Definition like '<Field Type=""%'
5.   Now check your site columns page URL (../_layouts/mngfield.aspx). Error will disappear.​

If you have any questions you can reach out our SharePoint Consulting team here.

Export& Import Content Type by powershell script

Export Content Type by power cell script:-

clear

   1:  write-host "Start..."
   2:  $sourceWeb = Get-SPWeb -Identity "http://br53:3000/"
   3:  write-host $sourceWeb.ContentTypes
   4:  #
   5:  $xmlFilePath = "C:\Script-SiteContentTypes.xml"
   6:  #
   7:  #Create Export File
   8:  New-Item $xmlFilePath -type file -force
   9:  #Export Content Types to XML file
  10:  Add-Content $xmlFilePath "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
  11:  Add-Content $xmlFilePath "`n<ContentTypes>"
  12:  $sourceWeb.ContentTypes | ForEach-Object {
  13:      if ($_.Group -eq "Custom Content Types") {
  14:          Add-Content $xmlFilePath $_.SchemaXml
  15:      }
  16:  }
  17:  Add-Content $xmlFilePath "</ContentTypes>"
  18:  $sourceWeb.Dispose()

Import Content Type by power cell script:-


   1:  #http://fazlulchowdhury.blogspot.in/2012/02/how-to-importexport-custom-content.html
   2:  clear 
   3:  $destWeb = Get-SPWeb -Identity "http://br53:1001/"
   4:  write-host $destWeb
   5:  $xmlFilePath = "C:\Script-SiteContentTypes.xml"
   6:  ##Create Site Content Types
   7:  $ctsXML = [xml](Get-Content($xmlFilePath))
   8:  $ctsXML.ContentTypes.ContentType | ForEach-Object {
   9:      #Create Content Type object inheriting from parent
  10:      $spContentType = New-Object Microsoft.SharePoint.SPContentType ($_.ID,$destWeb.ContentTypes,$_.Name)
  11:      #Set Content Type description and group
  12:      $spContentType.Description = $_.Description
  13:      $spContentType.Group = $_.Group
  14:      $_.Fields.Field  | ForEach-Object {
  15:          if(!$spContentType.FieldLinks[$_.DisplayName])
  16:          {
  17:              #Create a field link for the Content Type by getting an existing column
  18:  $spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($destWeb.Fields[$_.DisplayName])
  19:              #Check to see if column should be Optional, Required or Hidden
  20:              if ($_.Required -eq "TRUE") {$spFieldLink.Required = $true}
  21:              if ($_.Hidden -eq "TRUE") {$spFieldLink.Hidden = $true}
  22:              #Add column to Content Type
  23:              $spContentType.FieldLinks.Add($spFieldLink)
  24:          }
  25:      }
  26:      #Create Content Type on the site and update Content Type object
  27:      $ct = $destWeb.ContentTypes.Add($spContentType)
  28:      $spContentType.Update()
  29:      write-host "Content type" $ct.Name "has been created"
  30:  }
  31:  $destWeb.Dispose()


If you have any questions you can reach out our SharePoint Consulting team here.

Export & Import Site Columns by power script

Export Site Columns by power script:


   1:  $sourceWeb = Get-SPWeb -Identity "http://br53:3000/"
   2:  $xmlFilePath = "C:\Script-SiteColumns.xml"
   3:  #Create Export Files
   4:  New-Item $xmlFilePath -type file -force
   5:  #Export Site Columns to XML file
   6:  Add-Content $xmlFilePath "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
   7:  Add-Content $xmlFilePath "`n<Fields>"
   8:  $sourceWeb.Fields | ForEach-Object {
   9:      if ($_.Group -eq "Custom Columns") {
  10:          Add-Content $xmlFilePath $_.SchemaXml
  11:      }
  12:  }
  13:  Add-Content $xmlFilePath "</Fields>"
  14:  $sourceWeb.Dispose() 

Import Site Columns by power script:

clear

   1:  $destWeb = Get-SPWeb -Identity "http://br53:1001/"
   2:  $installPath = "C:"
   3:  #Get exported XML file
   4:  $fieldsXML = [xml](Get-Content($installPath + "\Script-SiteColumns.xml"))
   5:  $fieldsXML.Fields.Field | ForEach-Object {
   6:      #Configure core properties belonging to all column types
   7:      $fieldXML = '<Field Type="' + $_.Type + '"
   8:      Name="'
+ $_.Name + '"
   9:      ID="'
+ $_.ID + '"
  10:      Description="'
+ $_.Description + '"
  11:      DisplayName="'
+ $_.DisplayName + '"
  12:      StaticName="'
+ $_.StaticName + '"
  13:      Group="'
+ $_.Group + '"
  14:      Hidden="'
+ $_.Hidden + '"
  15:      Required="'
+ $_.Required + '"
  16:      Sealed="'
+ $_.Sealed + '"'
  17:      #Configure optional properties belonging to specific column types – you may need to add some extra properties here if present in your XML file
  18:      if ($_.ShowInDisplayForm) { $fieldXML = $fieldXML + "`n" + 'ShowInDisplayForm="' + $_.ShowInDisplayForm + '"'}
  19:      if ($_.ShowInEditForm) { $fieldXML = $fieldXML + "`n" + 'ShowInEditForm="' + $_.ShowInEditForm + '"'}
  20:      if ($_.ShowInListSettings) { $fieldXML = $fieldXML + "`n" + 'ShowInListSettings="' + $_.ShowInListSettings + '"'}
  21:      if ($_.ShowInNewForm) { $fieldXML = $fieldXML + "`n" + 'ShowInNewForm="' + $_.ShowInNewForm + '"'}
  22:      if ($_.EnforceUniqueValues) { $fieldXML = $fieldXML + "`n" + 'EnforceUniqueValues="' + $_.EnforceUniqueValues + '"'}
  23:      if ($_.Indexed) { $fieldXML = $fieldXML + "`n" + 'Indexed="' + $_.Indexed + '"'}
  24:      if ($_.Format) { $fieldXML = $fieldXML + "`n" + 'Format="' + $_.Format + '"'}
  25:      if ($_.MaxLength) { $fieldXML = $fieldXML + "`n" + 'MaxLength="' + $_.MaxLength + '"' }
  26:      if ($_.FillInChoice) { $fieldXML = $fieldXML + "`n" + 'FillInChoice="' + $_.FillInChoice + '"' }
  27:      if ($_.NumLines) { $fieldXML = $fieldXML + "`n" + 'NumLines="' + $_.NumLines + '"' }
  28:      if ($_.RichText) { $fieldXML = $fieldXML + "`n" + 'RichText="' + $_.RichText + '"' }
  29:      if ($_.RichTextMode) { $fieldXML = $fieldXML + "`n" + 'RichTextMode="' + $_.RichTextMode + '"' }
  30:      if ($_.IsolateStyles) { $fieldXML = $fieldXML + "`n" + 'IsolateStyles="' + $_.IsolateStyles + '"' }
  31:      if ($_.AppendOnly) { $fieldXML = $fieldXML + "`n" + 'AppendOnly="' + $_.AppendOnly + '"' }
  32:      if ($_.Sortable) { $fieldXML = $fieldXML + "`n" + 'Sortable="' + $_.Sortable + '"' }
  33:      if ($_.RestrictedMode) { $fieldXML = $fieldXML + "`n" + 'RestrictedMode="' + $_.RestrictedMode + '"' }
  34:      if ($_.UnlimitedLengthInDocumentLibrary) { $fieldXML = $fieldXML + "`n" + 'UnlimitedLengthInDocumentLibrary="' + $_.UnlimitedLengthInDocumentLibrary + '"' }
  35:      if ($_.CanToggleHidden) { $fieldXML = $fieldXML + "`n" + 'CanToggleHidden="' + $_.CanToggleHidden + '"' }
  36:      if ($_.List) { $fieldXML = $fieldXML + "`n" + 'List="' + $_.List + '"' }
  37:      if ($_.ShowField) { $fieldXML = $fieldXML + "`n" + 'ShowField="' + $_.ShowField + '"' }
  38:      if ($_.UserSelectionMode) { $fieldXML = $fieldXML + "`n" + 'UserSelectionMode="' + $_.UserSelectionMode + '"' }
  39:      if ($_.UserSelectionScope) { $fieldXML = $fieldXML + "`n" + 'UserSelectionScope="' + $_.UserSelectionScope + '"' }
  40:      if ($_.BaseType) { $fieldXML = $fieldXML + "`n" + 'BaseType="' + $_.BaseType + '"' }
  41:      if ($_.Mult) { $fieldXML = $fieldXML + "`n" + 'Mult="' + $_.Mult + '"' }
  42:      if ($_.ReadOnly) { $fieldXML = $fieldXML + "`n" + 'ReadOnly="' + $_.ReadOnly + '"' }
  43:      if ($_.FieldRef) { $fieldXML = $fieldXML + "`n" + 'FieldRef="' + $_.FieldRef + '"' }   
  44:      $fieldXML = $fieldXML + ">"
  45:      #Create choices if choice column
  46:      if ($_.Type -eq "Choice") {
  47:          $fieldXML = $fieldXML + "`n<CHOICES>"
  48:          $_.Choices.Choice | ForEach-Object {
  49:             $fieldXML = $fieldXML + "`n<CHOICE>" + $_ + "</CHOICE>"
  50:          }
  51:          $fieldXML = $fieldXML + "`n</CHOICES>"
  52:      }
  53:       #Set Default value, if specified  
  54:      if ($_.Default) { $fieldXML = $fieldXML + "`n<Default>" + $_.Default + "</Default>" }
  55:      #End XML tag specified for this field
  56:      $fieldXML = $fieldXML + "</Field>"
  57:       #Create column on the site
  58:      $destWeb.Fields.AddFieldAsXml($fieldXML.Replace("&","&amp;"))
  59:      write-host "Created site column" $_.DisplayName "on" $destWeb.Url
  60:      $destWeb.Dispose()
  61:  }​

If you have any questions you can reach out our SharePoint Consulting team here.