Showing posts with label Content Types. Show all posts
Showing posts with label Content Types. Show all posts

Monday, March 21, 2011

How To Add column to all content types and lists in SharePoint

Adding a column to all content types and list in SharePoint is simple, but there are implications that first need to be considered before doing so.  Once completed, the new column will be available in all existing content types in the Site Collection, as well as lists and libraries that exist on SharePoint sites.


Implication:
The implication of this change, is that the process to reverse is not nearly as simple as the process to implement. Removing the column from the content type(s) will not remove the association of the column with lists that previously had the global column.  A custom solution could be developed to automate removal of the column from content types and lists, but the alternative would be to manually remove each instance which could be time consuming in larger, more complex environments.


Process:
Content Types in SharePoint inherit from the Item content type.  If a column is added to this content type (with the “Update all content types inheriting from this type?” option selected), the column will also be added to all existing content types in the site collection.

  1. Navigate to the Content Type Gallery at the root of the site collection, via the site settings page
  2. From under the List Content Types heading, select the “Item” content type.
  3. Press the “Add from new site column”, link to add a new global column, or the add from existing option to add an existing column to all content types.
  4. (If adding a new column) Complete the information about the new column, ensure that the “Update all content types inheriting from this type?” option is selected, and press OK to add the column.

Sunday, August 15, 2010

Metadata Property Mappings - Managed Property not populating with data

Managed Property not populating with data


I was playing around with search scopes and result page XSL templates in order to develop a search solution that incorporates custom fields from a content type used on multiple site collections.  Content types containing custom columns that were to be searched across, as well as displayed in the search results.


The same content type has been reused multiple times across the primary site collection, and has also been deployed and used multiple time in other site collections.  When configuring managed metadata property mappings for the custom fields, I was able to map each field to a managed property by searching for the field name.


I was then able to create an advanced search page the included the custom properties.  When incorporating the additional managed properties into the search results, I found that only items from the original (primary) site collection would have data associated with the custom mappings.

The content type had been deployed to each site collection by deploying and enabling an InfoPath Form Service solution.  The content type created once enabled was then associated with the form library from each site collection.  I found that the internal column names from the content types on all site collections except for the primary site collection were set in the format of an Id, and not the text representation for column names the original content type.


To allow the managed properties to contain data from a particular column across each site collection, I needed to do one of the two things:


1. Remove and re-create the column on the site collections where the column names were set as Ids. This resulted in the column names reverting to the same text name of the equivalent column on the primary site collection.  The search crawler then maps data from the column on each site collection.  


Or: 


2. Update the managed properties so that each instance of the column in each site collection is mapped to the Managed Property in Central Administration.  To do this, I needed to obtain the internal column names, which in this case were in the same format as a list or column id in SharePoint.  When finding columns from the SharePoint farm to map to the managed property, searching for part of the column id resulted in the column being found.  After adding each instance of the columns from all site collections using the column ids, I then selected the option to “Include values from a single crawled property based on the order specified”.  This results in the managed property being populated with data from one of the mapped columns only, which will be the first one that contains data in the order specified.


After performing a full crawl of all site collections in the farm, the search results successfully incorporated the custom managed properties.  The advanced search now searched across all site collections to find items using values in the custom fields.

Sunday, October 18, 2009

InfoPath Error - Updating Content Type Failed When Publishing to SharePoint

When Publishing an InfoPath Form to a SharePoint site Content Type, the process may fail when trying to Update the Site Content Type if there are a large number of fields being promoted to SharePoint columns/fields in the Content Type with an "Updating Site content Type Failed" message.

One solution for this is to create a separate list with a lookup column/field back to the list which uses the Content Type created by InfoPath. The fields which are removed from the Content Type can be added to the separate list instead.

When the InfoPath Form is submitted, rules can be configured to create or update an item in the separate list which corresponds to the form being submitted, with the additional data.

How to Solve:

1. Make a full backup the InfoPath Form Template and the SharePoint Site (Content Types, Lists, etc.)

2. Choose which fields to add to the separate list instead of promoting/submitting with the form data.

3. Remove the fields from the list of promoted fields (Tools -> Form Options -> Property Promotion - or remove the fields when you next publish the form)

Note: Enough fields need to be removed to allow the form to be published successfully, as well as consistently. At this point, if you can't get the form to publish to a Content Type without receiving an "Error updating Content Type" (or similar) message by reducing the number of promoted fields, then the problem is caused elsewhere and the solution in this article will not apply.

4. Add a CAML XML template Data Connection to store the data required to add or update an item in the separate list. See InfoPath - Update Existing SharePoint List Item Programmatically Using CAML for details.

5. Add event handlers or and a main function to populate the CAML template with the data required to create or update an item in the separate list. See InfoPath - Update Repeating Elements/Nodes in a Secondary Data Source for details.

6. Create a Submit Data Connection which uses the UpdateListItems Web Service and the CAML template (created in Step 4) to create or update an item in the separate list. See InfoPath - Update Existing SharePoint List Item Programmatically Using CAML for details.

7. Configure rules to submit the CAML template using the Data Connection created in Step 6, then submit the form using the main submit data connection when the form is submitted. See InfoPath - Update Existing SharePoint List Item Programmatically Using CAML for details.

Tuesday, September 15, 2009

Custom Publishing Page Layout using SharePoint Designer













Overview:
This article demonstrates how to create a customised Publishing Page Layout which can be used to add publishing pages to a SharePoint site with publishing features enabled. The page will be created from a content type which contains additional fields which are to be displayed on the publishing page both when it is being edited and once it has been published. This article also demonstrates how to display fields only when a publishing page is being edited using an Edit Mode Panel if required.








1. Activate Publishing Features on the SharePoint site:
2. Create Publishing Layout Content Type
3. Create Publishing Layout from the Content Type
4. Customise the Publishing Layout using SharePoint Designer
5. Add the Content type to the Pages library on the SharePoint site
6. Create a new Page from The Custom Publishing Layout

Requirements:
  • SharePoint (MOSS 2007)
  • SharePoint's Publishing Features
  • SharePoint Designer (2007)
SharePoint Designer is now available for Free. Download SharePoint Designer from the Microsoft Website.


1. Activate Publishing Features on the SharePoint site:
Publishing features need to be enabled on the SharePoint site which uses the features. To ensure that publishing features are enabled, you can either create the SharePoint Site from the News, or Publishing Site templates, which have publishing features enabled, or enable the Publishing Features on an existing site in the site collection.

Check the status or enable/disable the Publishing Features on a SharePoint site:
  1. Go to the Site Settings page of the SharePoint site
  2. Select Site Features, located under the "Site Administration" heading.
  3. Enable Publishing Features if required.






Enabling Publishing Features on a SharePoint Site will:
  • Create a Documents, Images and Pages library to be used when creating publishing pages on the site. The Documents and Images libraries are used to store files or images which are uploaded when creating content using a Publishing Page Layout. The upload dialog allows a user to easily select the Site Collection Images library, or the current (Publishing) site image library for an image to be uploaded for use in a Publishing Page Layout.
  • Add the "Create Page" and "View All Site Content" options to the "Site Actions" menu of the site.

2. Create Publishing Layout Content Type
When creating or customising a publishing layout which is in an article format which has common fields that the OOB "Article Page" content type such as start and end dates, article title, body, audience, etc., it may be quicker to create the custom Publishing Layout Content Type from the Article Page content type. If you require a custom set of fields on the publishing page, create the content type from the "Page" content type which is a core component of the publishing feature provided by SharePoint.

Process:
- Create the Initial Content Type
  • Browse to the Content Type Library at the Site Collection root, or the content Type Library of the site which will use the Publishing Features.
  • Site Settings -> Site Content Types (under Galleries heading)










  • Select "Create" to add a new Content Type.














  • Enter a name for the content type and description if required.
  • Select the "Article Page", or "Page" Publishing Content Types. If you are creating a news article like page layout, it may be more efficient to create a custom Article Page and modifying to suit rather than starting from scratch.








- Add Additional Columns/Fields to the Content Type if required
  1. Additional metadata fields can now be added to the Publishing Layout Content Type if required, by following the same procedure as you would to add a field to any Content Type in SharePoint.
  2. Open the Content Type if required by selecting it from the content type library
  3. Select "Add from Existing Site Columns" if the additional metadata fields/columns are already available on the current SharePoint site, or select "Add from New Site Column" to create a new column.
In this example I have created an additional column called "Audience", which is a choice field with two options; Internal and External (Below).


















3. Create Publishing Layout from the Content Type
Once the Publishing Layout content Type has been created, a Publishing Layout can be added to the Materpage library by selecting the custom content type created in Step 2 from the options available when creating a new Masterpage or Page Layout.

Process:
  • Browse to the Site Collection Masterpage Library, or the Masterpage Library on the site which the Publishing Layout Content Type was added to in Step 2 if not the Site Collection root.












  • Press the "New" button on the Masterpage Library.
  • Select the Publishing Layout Content Type created in Step 2 from the list of options.
  • Give the Publishing Layout a short, but descriptive title, as this will be used to destinguish the Publishing Layout from others when selecting from the available options.









  • Press Ok to create the Page Layout.

4. Customise the Publishing Layout using SharePoint Designer
Once the Publishing Layout has been created from the content type containing the custom fields, it can the be opened using SharePoint Designer and modified as required. Additional fields from the Publishing Layout Content Type can be added to the layout to be displayed when the page is checked in or published. If a metadata field is required for the Publishing Page Layout, but does not need to be visible on the page once it has been published, Edit Mode Panels can be used to display the containing fields only when the page is being edited.

Process:
  • Using SharePoint Designer, open the Publishing Layout from the Masterpage Library created in Step 3, or select "Edit Using SharePoint Designer" if available on the Edit Menu of the custom Publishing Layout.

















  • Apply the required layout and formatting to the publishing page by creating empty regions/cells where content fields will be placed.
  • Open the Toolbox - Task Panes -> Toolbox
  • From under the Page Fields and Content Fields Headings, drag the required fields into the empty regions on the publishing page.





















CSS Styles
You can set the styles for content field elements on a Publishing Page using the "Tag Properties" task pane. Set the CSS class of the element to a class which has been set up to format display the element as required (See Below).




















Edit Mode Panels
In a Publishing Page Layout, fields inside an Edit Mode Panel not be visible when the page is not being edited. This allows metadata fields which are required for each publishing page to be added to the layout, but not displayed in the publishing page once checked in, or published as a major version.

How to Add an Edit Mode Panel to a Page Layout:
  • Open the Toolbox - Task Panes -> Toolbox
  • Under the Server Controls heading of the Toolbox in SharePoint Designer, drag the "EditModePanel" control into the required region of the publishing page.


















  • If using the code view only, the EditModePanel control can be added to the page by dragging the control into the required section of code, or by right clicking the control in the toolbox and selecting "Insert".
  • Add publishing layout field elements to the Edit Mode Panel by dragging the required content field into the Edit Mode Panel.
  • If using the code view only, add the content field tag to the Edit Mode Panel tag (See Below)













5. Add the Content type to the Pages library on the SharePoint site
Add to the list of available Page Layouts when creating a new page from a Publishing Page Layout, to include the custom Publishing Page in the list of options.
  • Browse to the Pages library of the SharePoint Publishing Site













  • Open the settings page for the Pages Library
Settings -> Document Library Settings









  • Select "Add from existing site content types".
  • Choose the Publishing Layout Content Type created in Step 2





  • Press Ok.

6. Create a new Page from The Custom Publishing Layout
A new page can now be created from the custom Publishing Page Layout by pressing the new button on the Pages library. Give the page a name and description, then select the Page Layout from the list of options and press the "Create" button to create the page.
















Once the page is Checked in or Published after it has been edited, it can be viewed in a browser by opting the address/URL to the page in the browser, or by selecting the page from the Pages Library of the publishing site.