Problem: Create a custom list to hold configuration values in a list.
Resolution Overview: Using VS 2010 create a feature that deploys the new list with content.
1.> Create Site Columns/fields;
2.> Create the Content Type using the Site Columns;
3.> Create the List Definition from the Content Type; and
4.> Add items to the list instance elements.xml.
Resolution Steps:
1.> Create Site Columns by adding a new "Empty Element" item in VS.
3.> Create the List Definition from the Content Type

Follow the wizard and select the newly created Content Type "Configuration";
Check the List definition has created the elements.xml and schema.xml files;

Edit the Schema.xml File to Show the new columns defined int he content type (otherwise you will only see the "Title" column);
Resolution Overview: Using VS 2010 create a feature that deploys the new list with content.
1.> Create Site Columns/fields;
2.> Create the Content Type using the Site Columns;
3.> Create the List Definition from the Content Type; and
4.> Add items to the list instance elements.xml.
Resolution Steps:
1.> Create Site Columns by adding a new "Empty Element" item in VS.
Declaratively add the site column to the elements.xml file;
Ensure your element file has been added to a feature for deployment;
Deploy the feature and ensure the Site Column has been add using the UI "Site Setting" > "Site Columns";
2.> Create the Content Type using the Site Columns
Using VS 2010 create a new Content Type;
Using the existing Site Column create the Content Type declaratively;
Check the Content Type is create after you have deployed;
3.> Create the List Definition from the Content Type
Follow the wizard and select the newly created Content Type "Configuration";
Check the List definition has created the elements.xml and schema.xml files;
Edit the Schema.xml File to Show the new columns defined int he content type (otherwise you will only see the "Title" column);
4.> Add items to the list instance elements.xml
Ensure the List is created
More Info: Creating a Custom field, Content Type, List def & List instance on MSDN PB Change: 27 Aug 2010
Tip: The fields/site columns & FieldRefs used in the elements files can be added thru the VS2010 tools. VS2010 > View > Toolbar
Tip: Updated 18 Oct 2010 - CKSDev has the functionality to import Site Columns, this is useful in that you may of created the SiteColumns via the UI on a prototype site and you can not easily get the xml to create the site columns/fields declaritively. http://blog.mastykarz.nl/cksdev-support-importing-site-columns/
Download: SharePoint 2010 sandbox project example that creates 2 lists with a lookup field. Updated 24/03/2011
0 comments:
Post a Comment