<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6407541290823102560</id><updated>2011-07-30T18:29:23.510-07:00</updated><category term='sharepoint'/><category term='content type'/><category term='filtered lookup field'/><category term='lookup field'/><title type='text'>Sharepoint Blog - Brandon</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sharepoint-brandon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6407541290823102560/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sharepoint-brandon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Brandon Herbertson</name><uri>http://www.blogger.com/profile/07635721316186773331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6407541290823102560.post-8295953449678064453</id><published>2010-02-10T02:03:00.001-08:00</published><updated>2010-02-11T01:28:33.705-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='content type'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='lookup field'/><category scheme='http://www.blogger.com/atom/ns#' term='filtered lookup field'/><title type='text'>How to create Filtered Lookup Field by Content Type</title><content type='html'>&lt;h1&gt;How to create Filtered Lookup Field by Content Type&lt;/h1&gt;&lt;strong&gt;Creating Filtered Lookup Field in Sharepoint is not directly supported.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;In order to filter lookup field you must install custom field from some open source project or etc. In scenairo in which we wont to filter lookup field by content type it is not necessary. Is is possible to do it with basic lookup field and showfield attribute of this lookup field.&lt;br /&gt;&lt;br /&gt;In this blog article i will show you on example how to create filtered lookup field by content type.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;You should follow these steps:&lt;/strong&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#creating-blank-site-definition"&gt;Create a Blank Site Definition&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#creating-source-list"&gt;Create source List for Lookup Field based on two or more Content Types&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#creating-list-with-filtered-lookup-fields"&gt;Create List with Filtered Lookup Fields&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#correcting-lookup-fields-at-runtime"&gt;Correct Lookup Fields at runtime&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#deploying-site-definition"&gt;Deploy Site definition&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#creating-site-from-site-definition"&gt;Create site from Site definition&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#testing-filtered-lookup-fields"&gt;Test Filtered Lookup Fields&lt;/a&gt;&lt;/li&gt;&lt;a name="creating-blank-site-definition"&gt;&lt;/a&gt;&lt;br /&gt;&lt;/ol&gt;&lt;a name="creating-blank-site-definition"&gt;&lt;/a&gt;&lt;h3&gt;1) Create a Blank Site Definition&lt;/h3&gt;- in Menu choose: File -&gt; New -&gt; Project&lt;br /&gt;- in tree list navigate to Sharepoint group and choose Blank Site Definition&lt;br /&gt;- fill the Name and Location of project and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating Blank Site definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3Fkbo7rYbI/AAAAAAAAACE/fPsfm6yQf8Y/s1600-h/creating-blank-site-definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 272px;" src="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3Fkbo7rYbI/AAAAAAAAACE/fPsfm6yQf8Y/s400/creating-blank-site-definition.png" border="0" alt="creating blank site definition" id="BLOGGER_PHOTO_ID_5436236651219870130" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="creating-source-list"&gt;&lt;/a&gt;&lt;h3&gt;2) Create source List for Lookup Field based on two or more Content Types&lt;/h3&gt;- right click Project in Solution Explorer&lt;br /&gt;- in context menu choose: Add -&gt; New Item&lt;br /&gt;- in tree list navigate to Sharepoint group and choose Content Type&lt;br /&gt;- fill the Name of Content Type and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating first Content Type" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fksb2ZqOI/AAAAAAAAACU/906Nr0AHyzM/s1600-h/creating-second-content-type.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 242px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fkmjq0xNI/AAAAAAAAACM/jp0ZiX6vcaU/s400/creating-first-content-type.png" border="0" alt="creating first content type" id="BLOGGER_PHOTO_ID_5436236838785565906" /&gt;&lt;/a&gt;&lt;br /&gt;- to create second content type again click to new item&lt;br /&gt;- fill the name of second content type and click ok&lt;br /&gt;- for both choose the Base content type: Item and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating second Content Type" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fkmjq0xNI/AAAAAAAAACM/jp0ZiX6vcaU/s1600-h/creating-first-content-type.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 242px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fksb2ZqOI/AAAAAAAAACU/906Nr0AHyzM/s400/creating-second-content-type.png" border="0" alt="creating second content type" id="BLOGGER_PHOTO_ID_5436236939765852386" /&gt;&lt;/a&gt;&lt;br /&gt;- custom content types edit as shown on picture&lt;br /&gt;- add reference to title node in order to hide it with attribute hidden&lt;br /&gt;- uncomment field prepared by visual studio and change its required flag to true&lt;br /&gt;&lt;br /&gt;&lt;a title="First Content Type definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fk01sz9yI/AAAAAAAAACc/-t6MunprqzM/s1600-h/first-content-type-definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 191px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fk01sz9yI/AAAAAAAAACc/-t6MunprqzM/s400/first-content-type-definition.png" border="0" alt="first content type definition" id="BLOGGER_PHOTO_ID_5436237084143908642" /&gt;&lt;/a&gt;&lt;br /&gt;- xml code of first content type:&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&lt;elements id="5ef2fdd1-1ffb-49ab-a14f-02942c2f7800" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;&lt;br /&gt; &lt;contenttype id="0x0100a12aff9523b2431e869a12eb05816dc8" name="FirstSourceListCT" group="Development" description="Developing Content Type" version="0"&gt;&lt;br /&gt;   &lt;fieldrefs&gt;&lt;br /&gt;     &lt;fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="Title" required="FALSE" hidden="TRUE"&gt;&lt;br /&gt;     &lt;fieldref id="{2e6cfed0-a3bc-49f5-90b1-4d56531a2384}" name="FirstSourceListCTField"&gt;&lt;br /&gt;   &lt;/fieldref&gt;&lt;/fieldref&gt;&lt;/fieldrefs&gt;&lt;br /&gt; &lt;/contenttype&gt;&lt;br /&gt; &lt;field id="{2e6cfed0-a3bc-49f5-90b1-4d56531a2384}" type="Text" name="FirstSourceListCTField" displayname="FirstSourceListCT Field" staticname="FirstSourceListCTField" hidden="FALSE" required="TRUE" sealed="FALSE"&gt;&lt;br /&gt;&lt;/field&gt;&lt;/elements&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;- do the same with second Content Type&lt;br /&gt;&lt;br /&gt;&lt;a title="Second Content Type definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3Fk6MkIwyI/AAAAAAAAACk/g-XkTKU2Z2s/s1600-h/second-content-type-definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 195px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3Fk6MkIwyI/AAAAAAAAACk/g-XkTKU2Z2s/s400/second-content-type-definition.png" border="0" alt="second content type definition" id="BLOGGER_PHOTO_ID_5436237176180884258" /&gt;&lt;/a&gt;&lt;br /&gt;- xml code of second content type:&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;elements id="873e578f-9567-4d9e-be95-dbf191b86f38" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;&lt;br /&gt; &lt;contenttype id="0x010059254c7a238b48b98005fa6f6462a382" name="SecondSourceListCT" group="Development" description="Developing Content Type" version="0"&gt;&lt;br /&gt;   &lt;fieldrefs&gt;&lt;br /&gt;     &lt;fieldref id="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" name="Title" required="FALSE" hidden="TRUE"&gt;&lt;br /&gt;     &lt;fieldref id="{ba62c5e4-73ae-43f2-b4f6-7299339f6bc0}" name="SecondSourceListCTField"&gt;&lt;br /&gt;   &lt;/fieldref&gt;&lt;/fieldref&gt;&lt;/fieldrefs&gt;&lt;br /&gt; &lt;/contenttype&gt;&lt;br /&gt; &lt;field id="{ba62c5e4-73ae-43f2-b4f6-7299339f6bc0}" type="Text" name="SecondSourceListCTField" displayname="SecondSourceListCT Field" staticname="SecondSourceListCTField" hidden="FALSE" required="TRUE" sealed="FALSE"&gt;&lt;br /&gt;&lt;/field&gt;&lt;/elements&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;- the next step is creating List Definition and List Instance from two content types&lt;br /&gt;- right click Project in Solution Explorer&lt;br /&gt;- in context menu choose: Add -&gt; New Item&lt;br /&gt;- in tree list navigate to Sharepoint group and choose List Definition notice that in this scenairo we dont use option List definition from content type, we are adding content types to list definition manually&lt;br /&gt;- fill the Name of List Definition and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating source List definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlG5X9ISI/AAAAAAAAACs/Ujegu2zgVbU/s1600-h/creating-source-list-definition-1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 242px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlG5X9ISI/AAAAAAAAACs/Ujegu2zgVbU/s400/creating-source-list-definition-1.png" border="0" alt="creating source list definition" id="BLOGGER_PHOTO_ID_5436237394367815970" /&gt;&lt;/a&gt;&lt;br /&gt;- choose the Base content type for example: Contacts&lt;br /&gt;- check Create List Instance and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating source List definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlL2ChrSI/AAAAAAAAAC0/nT0SS5rqt8U/s1600-h/creating-source-list-definition-2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 386px; height: 175px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlL2ChrSI/AAAAAAAAAC0/nT0SS5rqt8U/s400/creating-source-list-definition-2.png" border="0" alt="creating source list definition" id="BLOGGER_PHOTO_ID_5436237479371975970" /&gt;&lt;/a&gt;&lt;br /&gt;- next step is to associate two content types with list manually&lt;br /&gt;- locate and open for edit file schema.xml of created list in solution explorer&lt;br /&gt;- clear subnodes of ContentTypes node and Fields node&lt;br /&gt;- add attribute EnableContentTypes to List node&lt;br /&gt;- add two ContentTypeRef nodes under contentTypes node as shown on picture&lt;br /&gt;- notice that id of contenttypere is based on content type id from its xml definition&lt;br /&gt;- under the node Fields copy all nodes that are in custom content types&lt;br /&gt;&lt;br /&gt;&lt;a title="Source List definition Schema" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3FlZLNpZvI/AAAAAAAAAC8/sn5jOyDcXBA/s1600-h/source-list-definition-schema.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 218px;" src="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3FlZLNpZvI/AAAAAAAAAC8/sn5jOyDcXBA/s400/source-list-definition-schema.png" border="0" alt="source list definition schema" id="BLOGGER_PHOTO_ID_5436237708394063602" /&gt;&lt;/a&gt;&lt;br /&gt;- xml code of source list definition in schema.xml file:&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;list ows="Microsoft SharePoint" enablecontenttypes="TRUE" title="SourceList" foldercreation="FALSE" direction="$Resources:Direction;" url="Lists/SourceList" basetype="0" name="SourceList" id="1a483f9f-bf02-46e4-b2c3-2e9eb07653c0" type="100" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;&lt;br /&gt; &lt;metadata&gt;&lt;br /&gt;   &lt;contenttypes&gt;&lt;br /&gt;     &lt;contenttyperef id="0x0100a12aff9523b2431e869a12eb05816dc8"&gt;&lt;br /&gt;     &lt;contenttyperef id="0x010059254c7a238b48b98005fa6f6462a382"&gt;&lt;br /&gt;   &lt;/contenttyperef&gt;&lt;/contenttyperef&gt;&lt;/contenttypes&gt;&lt;br /&gt;   &lt;fields&gt;&lt;br /&gt;     &lt;field id="{2e6cfed0-a3bc-49f5-90b1-4d56531a2384}" type="Text" name="FirstSourceListCTField" displayname="FirstSourceListCT Field" staticname="FirstSourceListCTField" hidden="FALSE" required="TRUE" sealed="FALSE"&gt;&lt;br /&gt;     &lt;field id="{ba62c5e4-73ae-43f2-b4f6-7299339f6bc0}" type="Text" name="SecondSourceListCTField" displayname="SecondSourceListCT Field" staticname="SecondSourceListCTField" hidden="FALSE" required="TRUE" sealed="FALSE"&gt;&lt;br /&gt;   &lt;/field&gt;&lt;/field&gt;&lt;/fields&gt;&lt;br /&gt;&lt;/metadata&gt;&lt;/list&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="creating-list-with-filtered-lookup-fields"&gt;&lt;/a&gt;&lt;h3&gt;3) Create List with Filtered Lookup Fields&lt;/h3&gt;- right click Project in Solution Explorer&lt;br /&gt;- in context menu choose: Add -&gt; New Item&lt;br /&gt;- in tree list navigate to Sharepoint group and choose Content Type&lt;br /&gt;- fill the Name of Content Type and click OK&lt;br /&gt;- choose the Base content type: Item and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating Filtered Lookup Field Content Type" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlhrbKGVI/AAAAAAAAADE/kJMM1UKloTg/s1600-h/creating-filtered-lookup-field-content-type.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 242px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FlhrbKGVI/AAAAAAAAADE/kJMM1UKloTg/s400/creating-filtered-lookup-field-content-type.png" border="0" alt="creating filtered lookup field content type" id="BLOGGER_PHOTO_ID_5436237854479620434" /&gt;&lt;/a&gt;&lt;br /&gt;- now you have to add custom field to xml definition of content type&lt;br /&gt;- open SourceListCT.xml file to edit from Solution Explorer&lt;br /&gt;- uncomment FieldRef and Field node which is creating automatically by Visual Studio&lt;br /&gt;- copy FieldRef and Field node, change guids of second field and rename it&lt;br /&gt;- change type of fieds from Type="Text" to Type="Lookup"&lt;br /&gt;- add attribute List and attribute ShowField as shown in picture&lt;br /&gt;- your content type definition should look following:&lt;br /&gt;&lt;br /&gt;&lt;a title="Lookup Field Content Type definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3Flu_k9zII/AAAAAAAAADM/oDECgZKhZrI/s1600-h/lookup-field-content-type-definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 281px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3Flu_k9zII/AAAAAAAAADM/oDECgZKhZrI/s400/lookup-field-content-type-definition.png" border="0" alt="lookup field content type definition" id="BLOGGER_PHOTO_ID_5436238083227765890" /&gt;&lt;/a&gt;&lt;br /&gt;- xml code of Lookup Field list Content Type:&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;elements id="299aad39-8fef-4d87-a120-639fa61f38a7" xmlns="http://schemas.microsoft.com/sharepoint/"&gt;&lt;br /&gt; &lt;contenttype id="0x0100d0a3139011094bfa9753dab9143b25ae" name="LookupFieldListCT" group="Development" description="Developing Content Type" version="0"&gt;&lt;br /&gt;   &lt;fieldrefs&gt;&lt;br /&gt;     &lt;fieldref id="{26d5eaf3-fc36-427f-a165-2124f0b24728}" name="LookupFieldListCTFieldFirst"&gt;&lt;br /&gt;     &lt;fieldref id="{853BB7A4-BDE5-4a10-A401-9099DC7B30F3}" name="LookupFieldListCTFieldSecond"&gt;&lt;br /&gt;   &lt;/fieldref&gt;&lt;/fieldref&gt;&lt;/fieldrefs&gt;&lt;br /&gt; &lt;/contenttype&gt;&lt;br /&gt; &lt;field id="{26d5eaf3-fc36-427f-a165-2124f0b24728}" type="Lookup" name="LookupFieldListCTFieldFirst" displayname="LookupFieldListCTFirst Field" staticname="LookupFieldListCTFieldFirst" hidden="FALSE" required="FALSE" sealed="FALSE" list="{11111111-2222-3333-4444-555555555555}" showfield="FirstSourceListCTField"&gt;&lt;br /&gt; &lt;field id="{853BB7A4-BDE5-4a10-A401-9099DC7B30F3}" type="Lookup" name="LookupFieldListCTFieldSecond" displayname="LookupFieldListCTSecond Field" staticname="LookupFieldListCTFieldSecond" hidden="FALSE" required="FALSE" sealed="FALSE" list="{aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee}" showfield="SecondSourceListCTField"&gt;&lt;br /&gt;&lt;/field&gt;&lt;/field&gt;&lt;/elements&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;- when you have added lookup fields to content type definition and saved the xml file the next step is creating List Definition and List Instance&lt;br /&gt;- right click Project in Solution Explorer&lt;br /&gt;- in context menu choose: Add -&gt; New Item&lt;br /&gt;- in tree list navigate to Sharepoint group and choose List Definition from Content Type&lt;br /&gt;- fill the Name of List Definition and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating Lookup Field List definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3Fl0cj4lMI/AAAAAAAAADU/uZ3CDcLSjoQ/s1600-h/creating-lookup-field-list-definition-1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 242px;" src="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3Fl0cj4lMI/AAAAAAAAADU/uZ3CDcLSjoQ/s400/creating-lookup-field-list-definition-1.png" border="0" alt="creating lookup field list definition" id="BLOGGER_PHOTO_ID_5436238176907203778" /&gt;&lt;/a&gt;&lt;br /&gt;- choose the Base content type: SourceListCT&lt;br /&gt;- check Create List Instance and click OK&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating Lookup Field List definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3Fl5Cc7KXI/AAAAAAAAADc/rxgV32QH3ds/s1600-h/creating-lookup-field-list-definition-2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 386px; height: 145px;" src="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3Fl5Cc7KXI/AAAAAAAAADc/rxgV32QH3ds/s400/creating-lookup-field-list-definition-2.png" border="0" alt="creating lookup field list definition" id="BLOGGER_PHOTO_ID_5436238255798036850" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="correcting-lookup-fields-at-runtime"&gt;&lt;/a&gt;&lt;h3&gt;4) Correct Lookup Fields at runtime&lt;/h3&gt;- the attribute List of lookup field should contains the correct guid of SourceList, but the guid for sourceList are assigned in time of creation the list instance that is the reason why must be guid get from created list and set to lookup field at runtime&lt;br /&gt;- open SiteProvisioning.cs code file from Solution Explorer&lt;br /&gt;- to OnActivated method add CorrectLookupLists method call&lt;br /&gt;- add general CorrectLookupLists method to SiteProvisioningClass&lt;br /&gt;- your SiteProvisioning.cs file should look following:&lt;br /&gt;&lt;br /&gt;&lt;a title="Site provisioning handler" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fl_Z758xI/AAAAAAAAADk/VMjoQuq24do/s1600-h/site-provisioning-handler-1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 263px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fl_Z758xI/AAAAAAAAADk/VMjoQuq24do/s400/site-provisioning-handler-1.png" border="0" alt="site provisioning handler" id="BLOGGER_PHOTO_ID_5436238365181211410" /&gt;&lt;/a&gt;&lt;br /&gt;- code in OnActivated method:&lt;br /&gt;&lt;pre class="brush: cpp"&gt;&lt;br /&gt;CorrectLookupList(_web, "SourceList instance", "LookupFieldList instance",&lt;br /&gt; "LookupFieldListCTFirst Field", "11111111-2222-3333-4444-555555555555");&lt;br /&gt;CorrectLookupList(_web, "SourceList instance", "LookupFieldList instance",&lt;br /&gt; "LookupFieldListCTSecond Field", "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;- method CorrectLookupList:&lt;br /&gt;&lt;br /&gt;&lt;a title="Site provisioning handler" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3FmHp9JocI/AAAAAAAAADs/BHxA-c4PNy4/s1600-h/site-provisioning-handler-2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 248px;" src="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3FmHp9JocI/AAAAAAAAADs/BHxA-c4PNy4/s400/site-provisioning-handler-2.png" border="0" alt="site provisioning handler" id="BLOGGER_PHOTO_ID_5436238506920354242" /&gt;&lt;/a&gt;&lt;br /&gt;- code of this method to copy and paste:&lt;br /&gt;&lt;pre class="brush: cpp"&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Corrects the List attribute of lookup field&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// Instance of current spweb&lt;br /&gt;/// Name of source list for lookup field&lt;br /&gt;/// Name of list with lookup field&lt;br /&gt;/// Lookup field display name&lt;br /&gt;/// Temporary guid assigned to List attribute&lt;br /&gt;private void CorrectLookupList(SPWeb _web, string _sourceListName,&lt;br /&gt;   string _lookupFieldListName, string _lookupFieldName, string _tempGuid)&lt;br /&gt;{&lt;br /&gt;   SPList _sourceList = _web.Lists[_sourceListName];&lt;br /&gt;   SPList _lookupFieldList = _web.Lists[_lookupFieldListName];&lt;br /&gt;   _lookupFieldList.Fields[_lookupFieldName].SchemaXml =&lt;br /&gt;       _lookupFieldList.Fields[_lookupFieldName].SchemaXml.Replace(_tempGuid,&lt;br /&gt;       _sourceList.ID.ToString());&lt;br /&gt;   _lookupFieldList.Update();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="deploying-site-definition"&gt;&lt;/a&gt;&lt;h3&gt;5) Deploy Site definition&lt;/h3&gt;- right click project in Solution Explorer and in menu choose Properties&lt;br /&gt;- on Debug tab set Start action to Start browser with URL and define url address of sharepoint cetral administration site, in my case: http://localhost:18060/&lt;br /&gt;- save project properties&lt;br /&gt;- right click project again and choose: Deploy&lt;br /&gt;- in status bar you should see: Deploy succeeded&lt;br /&gt;&lt;br /&gt;&lt;a name="creating-site-from-site-definition"&gt;&lt;/a&gt;&lt;h3&gt;6) Create site from Site definition&lt;/h3&gt;- go to your central administration and choose tab Application Management&lt;br /&gt;- in group Sharepoint Site Management click Create site collection&lt;br /&gt;- fill title of site and optionally description&lt;br /&gt;- click on the development tab and choose BlankSiteDefinitionDemo&lt;br /&gt;- fill administrator user name and click ok&lt;br /&gt;- after while you should see status: Top-Level Site Successfully Created&lt;br /&gt;- now click the new created site link&lt;br /&gt;- when you made change to code of project you should also call from command prompt iisreset&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating site from Site definition" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3FmOMPOPhI/AAAAAAAAAD0/kQguuYSg2Yo/s1600-h/creating-site-from-site-definition.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 318px; height: 400px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3FmOMPOPhI/AAAAAAAAAD0/kQguuYSg2Yo/s400/creating-site-from-site-definition.png" border="0" alt="creating site from site definition" id="BLOGGER_PHOTO_ID_5436238619202174482" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a name="testing-filtered-lookup-fields"&gt;&lt;/a&gt;&lt;h3&gt;7) Test Filtered Lookup fields&lt;/h3&gt;- click View all Site Content to show created lists&lt;br /&gt;&lt;br /&gt;&lt;a title="Sharepoint site" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3FmUzFc4aI/AAAAAAAAAD8/dl8VVVCYsKQ/s1600-h/sharepoint-site.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 313px;" src="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3FmUzFc4aI/AAAAAAAAAD8/dl8VVVCYsKQ/s400/sharepoint-site.png" border="0" alt="sharepoint site" id="BLOGGER_PHOTO_ID_5436238732709388706" /&gt;&lt;/a&gt;&lt;br /&gt;- create some items in source list from diferrent content types&lt;br /&gt;&lt;br /&gt;&lt;a title="Creating items for Filtered Lookup Field" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fmh80rkkI/AAAAAAAAAEU/0GHvxPmBM4k/s1600-h/items-for-filtered-lookup-field-1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 144px;" src="http://2.bp.blogspot.com/_6G8K0PhUUu0/S3Fmh80rkkI/AAAAAAAAAEU/0GHvxPmBM4k/s400/items-for-filtered-lookup-field-1.png" border="0" alt="creating items for filtered lookup field" id="BLOGGER_PHOTO_ID_5436238958661702210" /&gt;&lt;/a&gt;&lt;br /&gt;- sourcelist main view should be alterned to display fields of content types&lt;br /&gt;&lt;br /&gt;&lt;a title="Adjusting List View" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3F4GibJIDI/AAAAAAAAAGU/qX8uT4Eazo8/s1600-h/adjusting-list-view.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 231px;" src="http://3.bp.blogspot.com/_6G8K0PhUUu0/S3F4GibJIDI/AAAAAAAAAGU/qX8uT4Eazo8/s400/adjusting-list-view.png" border="0" alt="adjusting list view" id="BLOGGER_PHOTO_ID_5436258278928097330" /&gt;&lt;/a&gt;&lt;br /&gt;- created items to demonstrate Filtered Lookup Field&lt;br /&gt;&lt;br /&gt;&lt;a title="Items for Filtered Lookup Field" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3FmfopvLPI/AAAAAAAAAEM/RFljJ9wul1g/s1600-h/items-for-filtered-lookup-field-2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 167px;" src="http://1.bp.blogspot.com/_6G8K0PhUUu0/S3FmfopvLPI/AAAAAAAAAEM/RFljJ9wul1g/s400/items-for-filtered-lookup-field-2.png" border="0" alt="items for filtered lookup field" id="BLOGGER_PHOTO_ID_5436238918887353586" /&gt;&lt;/a&gt;&lt;br /&gt;- when you click new in lookupfieldlist, you should see dropdown list with sourcelist items&lt;br /&gt;&lt;br /&gt;&lt;a title="Filtered Lookup Field" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FmcBo82RI/AAAAAAAAAEE/qo_DF0339Z8/s1600-h/filtered-lookup-field.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 184px;" src="http://4.bp.blogspot.com/_6G8K0PhUUu0/S3FmcBo82RI/AAAAAAAAAEE/qo_DF0339Z8/s400/filtered-lookup-field.png" border="0" alt="Filtered Lookup Field" id="BLOGGER_PHOTO_ID_5436238856875464978" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Filtered Lookup Field is successfuly created. Field is filtered by Content Type.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#top"&gt;Back to Top&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6407541290823102560-8295953449678064453?l=sharepoint-brandon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sharepoint-brandon.blogspot.com/feeds/8295953449678064453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6407541290823102560/posts/default/8295953449678064453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6407541290823102560/posts/default/8295953449678064453'/><link rel='alternate' type='text/html' href='http://sharepoint-brandon.blogspot.com/2010/02/how-to-create-filtered-lookup-field-by.html' title='How to create Filtered Lookup Field by Content Type'/><author><name>Brandon Herbertson</name><uri>http://www.blogger.com/profile/07635721316186773331</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_6G8K0PhUUu0/S3Fkbo7rYbI/AAAAAAAAACE/fPsfm6yQf8Y/s72-c/creating-blank-site-definition.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
