tag:blogger.com,1999:blog-4126985520350746834.post3197227629520520818..comments2024-03-28T07:00:21.554+00:00Comments on Chris O'Brien: Feature to create lookup fields on CodeplexChris O'Brienhttp://www.blogger.com/profile/10022906552670607366noreply@blogger.comBlogger21125tag:blogger.com,1999:blog-4126985520350746834.post-87110358297305649882008-11-30T22:56:00.000+00:002008-11-30T22:56:00.000+00:00@Brian Bilbro,That's a great tip - logically think...@Brian Bilbro,<BR/><BR/>That's a great tip - logically thinking about what's going on there, I shouldn't be surprised that works. I guess either way some code needs to be run so it could be a matter of preference as to the where/what.<BR/><BR/>In general though, the fact that the SchemaXml property is writable and can be used for schema updates opens some great possibilities :-)<BR/><BR/>Cheers,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-64777317830632653832008-11-30T22:29:00.000+00:002008-11-30T22:29:00.000+00:00@ben,Sorry, don't have an answer on this one. If t...@ben,<BR/><BR/>Sorry, don't have an answer on this one. If this column is of Person/Group type and this column type cannot be used as a lookup, it could just be that it isn't supported.<BR/><BR/>Sorry I can't be more help,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-10987908663602531782008-11-06T19:22:00.000+00:002008-11-06T19:22:00.000+00:00Hi Chris, Thanks for the blog posts. These are g...Hi Chris,<BR/> Thanks for the blog posts. These are great. My team is just now getting into SharePoint and these are great resources.<BR/><BR/>I just wanted to pass along some info. I'm doing the exact same thing as John Haigh above. However, I had a slight variation. I don't add the lookup column dynamically. I add as normal through the CAML definition files. <BR/><BR/>What I do is just update the existing field with the correct list reference. I kinda prefer that method since everything else can be defined as normal.<BR/><BR/>here's my change:<BR/><BR/>SPList applicationsList = web.Lists["MercerApplicationsListDefinition instance"];<BR/><BR/>SPList projectsList = web.Lists["MercerProjectsListDefinition instance"];<BR/><BR/>projectsList.Fields["Applications"].SchemaXml = projectsList.Fields["Applications"].SchemaXml.Replace("fd648b7f-9e58-469e-b1cf-5d365e26764c", applicationsList.ID.ToString());<BR/><BR/>projectsList.Update();Brian Bilbrohttps://www.blogger.com/profile/02262403719896915690noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-4347320916674692292008-11-06T15:20:00.000+00:002008-11-06T15:20:00.000+00:00Chris - my question to look up columns is this. Wh...Chris - <BR/><BR/>my question to look up columns is this. Why can't the Assigned To Column in a task list be used as a look up Column.<BR/><BR/>I have a workflow associated with a document library and I would like to have who the workflow is assigned to as a column in my document library. <BR/><BR/>Would this feature be able to do something like that? Is that possible?bstorihttps://www.blogger.com/profile/12797787262086260223noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-16467024103557269552008-07-11T19:00:00.000+01:002008-07-11T19:00:00.000+01:00Hi Adrian,I think that's the expected behaviour.In...Hi Adrian,<BR/><BR/>I think that's the expected behaviour.<BR/><BR/>In addition to removing the field from any lists, you would need also need to remove it from any content types (or delete the content type) before the field can be deleted.<BR/><BR/>If you also delete from the content type you should be OK.<BR/><BR/>HTH,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-12743645549016091392008-07-11T12:11:00.000+01:002008-07-11T12:11:00.000+01:00Hi, great explanation. However, I've a problem. Wh...Hi, great explanation. However, I've a problem. When the code tries to delete the column, i get an error, saying that it's still associated with a list or content type.<BR/><BR/>Looking at the site, there are no other lists there, so that's not the problem. However, in the FeatureActivated event, which actually calls the deletion code, it seems that the content type containing this lookup site column is already deployed (i can find it using the object model while in a breakpoint in the debugger) and I guess that's why the deletion won't work. Do you have any idea why I get this behaviour?<BR/><BR/>Thanks,<BR/>AdrianAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-23640336728878100762007-11-09T14:31:00.000+00:002007-11-09T14:31:00.000+00:00Hi John,Good to hear you got sorted. Thanks for po...Hi John,<BR/><BR/>Good to hear you got sorted. Thanks for posting the code!<BR/><BR/>Cheers,<BR/><BR/>Chris.<BR/><BR/>P.S. In response to your earlier comment, if you were going down the Feature route you wouldn't be able to use VSeWSS for this. This is because VSeWSS doesn't support feature receivers and regenerates the files on every build. <BR/><BR/><I>However</I>, it is possible with <A HREF="http://sharepointnutsandbolts.blogspot.com/2007/09/improvements-in-vsewss-11-ctp.html" REL="nofollow">VSeWSS 1.1 CTP</A>, since this allows you the developer to add to the feature files by hand. Note though this is still just at 'preview release' stage, so there could be the odd bug.<BR/><BR/>HTH,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-8866909967204158312007-11-09T01:45:00.000+00:002007-11-09T01:45:00.000+00:00Hi Chris,I was able to find a workaround in sitepr...Hi Chris,<BR/><BR/>I was able to find a workaround in siteprovision.cs.<BR/><BR/>Here is the code that worked to create the lookup field:<BR/><BR/>Inside OnActivated I added the following code:<BR/><BR/>SPWeb web;<BR/>SPSite site;<BR/><BR/>if (properties.Feature.Parent is SPWeb)<BR/>{<BR/>web = properties.Feature.Parent as SPWeb;<BR/>site = web.Site;<BR/>}<BR/>else<BR/>{<BR/>site = properties.Feature.Parent as SPSite;<BR/>web = site.RootWeb;<BR/>}<BR/><BR/>web.AllowUnsafeUpdates = true;<BR/><BR/>SPList addressList = web.Lists["AddressCTList"];<BR/>SPList provinceList = web.Lists["ProvinceCTList"];<BR/><BR/>provinceList.Fields.AddLookup("RelAddress", addressList.ID, true);<BR/>provinceList.Update();<BR/><BR/>Thanks,<BR/><BR/>JohnJohn Haighhttps://www.blogger.com/profile/07930136480971461612noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-31148247804885985562007-11-08T01:45:00.000+00:002007-11-08T01:45:00.000+00:00Hi Chris,I chopped out the code you wrote and adde...Hi Chris,<BR/><BR/>I chopped out the code you wrote and added into SiteProvisioning.cs, updated a lookup field in the XML file that will have the GUID replaced, deployed through VSeWSS and then created a site and I get this error when creating a site "Value does not fall within the expected range." I did a google search and found that the problem may be within the XML and then doubled checked the XML.<BR/><BR/>The other concern after reading your articles is that my sense is that I can't do this through VSeWSS and I need create a stand alone Solution with a Feature/Feature Receiver as you did in this article (codeplex etc.) and move all Content Types, Lists, etc. into a VS solution as you outlined in your articles "Automatically setting custom permissions on new sites" or "Creating, deploying and updating custom site definitions"<BR/><BR/>Is this the case?<BR/><BR/>Thanks,<BR/><BR/>JohnJohn Haighhttps://www.blogger.com/profile/07930136480971461612noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-88435583967179073772007-11-06T14:57:00.000+00:002007-11-06T14:57:00.000+00:00This is great news. I will let you know how it goe...This is great news. I will let you know how it goes and when successful I'll send my code over so that hopefully it can be posted so others can benefit.<BR/><BR/>Thanks,<BR/><BR/>JohnJohn Haighhttps://www.blogger.com/profile/07930136480971461612noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-49195497875564736952007-11-06T14:32:00.000+00:002007-11-06T14:32:00.000+00:00Hi John,Absolutely - I can't think of any reason w...Hi John,<BR/><BR/>Absolutely - I can't think of any reason why this wouldn't work. There's probably a couple of approaches:<BR/><BR/>- chop out the code I use and add it to your SiteProvisioning.cs (as you suggest)<BR/>- use <A HREF="http://sharepointnutsandbolts.blogspot.com/2007/05/feature-stapling.html" REL="nofollow">Feature stapling</A> to link the code to the site definition<BR/><BR/>Either should do the job. Let me know how you get on.<BR/><BR/>Cheers,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-73620358922212133642007-11-06T14:17:00.000+00:002007-11-06T14:17:00.000+00:00Hi Chris,I think this article is great. I have a S...Hi Chris,<BR/><BR/>I think this article is great. <BR/><BR/>I have a Site Definition Solution that I created through VSeWSS that has two content types(i.e Contact and Address), <BR/>and then two lists "ContactList" and "AddressList" created from these content types. <BR/>The second content type "Address" has a lookup field "RelatedContact" that refers to the ContactList. <BR/><BR/>Is it possible to add the feature receiver solution you wrote here that is on codeplex into my Site Definition Solution specifically into <BR/>SiteProvisioning.cs (done through SiteProvisioning.cs as mentioned above) so that when the site is provisioned<BR/>the lookup field has the proper GUID that references the GUID for the ContactList that WSS created when the Site was provisioned?<BR/><BR/>Thanks,<BR/><BR/>John HaighJohn Haighhttps://www.blogger.com/profile/07930136480971461612noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-70934077481874454042007-10-29T19:03:00.000+00:002007-10-29T19:03:00.000+00:00Hi Jessica,Hmm, I've not looked at adding columns ...Hi Jessica,<BR/><BR/>Hmm, I've not looked at adding columns to a list definition in this way I'm afraid. But I would have thought you'd need to add the FieldRef entries to the list's schema.xml file. I note there's 'fields' element in here, so that might be the place.<BR/><BR/>HTH,<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-66993357391039618492007-10-22T18:29:00.000+01:002007-10-22T18:29:00.000+01:00Chris,I've used this blog entry to get just what I...Chris,<BR/><BR/>I've used this blog entry to get just what I needed to create site columns based on lookup lists. Thanks for the help! Now, the next bridge I have to cross is integrating these into a list definition. I can get the lookup list site columns into a content type, because that uses FieldRef but when creating a list definition, you basically have to redefine each field even if they are in the content type (which, BTW, I find annoying :) ). Any ideas?<BR/><BR/>Thanks,<BR/>JessicaJessica Hardyhttps://www.blogger.com/profile/04229859935335816737noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-76534758206564458752007-09-11T14:44:00.000+01:002007-09-11T14:44:00.000+01:00Hi Bruce,Sterling work, many thanks for contributi...Hi Bruce,<BR/><BR/>Sterling work, many thanks for contributing.<BR/><BR/>I've updated the source code and checked in a new release with the update.<BR/><BR/>Much appreciated..<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-23623318344341550572007-09-10T14:20:00.000+01:002007-09-10T14:20:00.000+01:00No worries,I found the problem, needs a line of co...No worries,<BR/>I found the problem, needs a line of code replaced as at http://www.codeplex.com/SP2007LookupFields/WorkItem/View.aspx?WorkItemId=5485Bruce Sandemanhttps://www.blogger.com/profile/11946945712779674579noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-39539253844161820212007-09-10T12:50:00.000+01:002007-09-10T12:50:00.000+01:00Hi Chris,Very useful code, but for some reason I c...Hi Chris,<BR/>Very useful code, but for some reason I can only make it work for the first column defined within the fields xml file.<BR/><BR/>I can happily change the first field's name and it is created differently, but with multiple fields in there it does not seem to work.<BR/>Can you give me any pointers?<BR/>thanks<BR/>BruceBruce Sandemanhttps://www.blogger.com/profile/11946945712779674579noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-25633794842734051742007-07-27T10:15:00.000+01:002007-07-27T10:15:00.000+01:00Thanks for the feedback Matt, much appreciated!Chr...Thanks for the feedback Matt, much appreciated!<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-89921072220647124982007-07-27T09:59:00.000+01:002007-07-27T09:59:00.000+01:00Hey ChrisMeant to leave a comment earlier to thank...Hey Chris<BR/><BR/>Meant to leave a comment earlier to thank you for this project. I downloaded it and had it up and running in hours with the minimum of tweaks. What I really like about it is the generic approach you've taken that means the specifics of the particular site columns being targetted are all held in config files - spot on! It works like a charm and "feels" like the right way to manage this vital configuration step.<BR/><BR/>Nice one.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-23918362481231092362007-07-23T17:54:00.000+01:002007-07-23T17:54:00.000+01:00Hi,Yes, so assuming you are creating a VS project ...Hi,<BR/><BR/>Yes, so assuming you are creating a VS project with one of the templates which come with VSeWSS, there will be a file called SiteProvisioning.cs in your solution. <BR/><BR/>I've not had any particular problems with this - I can write code which modifies the site with no issues. I might write a post with more details though, as it's an area with a lot of possibilities.<BR/><BR/>What problems are you having?<BR/><BR/>Chris.Chris O'Brienhttps://www.blogger.com/profile/10022906552670607366noreply@blogger.comtag:blogger.com,1999:blog-4126985520350746834.post-36419549096376674482007-07-19T12:51:00.000+01:002007-07-19T12:51:00.000+01:00Hi Chris.Great job. This actually works. But I hav...Hi Chris.<BR/>Great job. This actually works. But I have a nother question for you. How could I implement a feature receiver wich starts when i create a new instance of my Site Definition? Visual Studio provides something like a Site Provisioning Handler-Class SiteProvisioning.cs - but I figuered out it actually does not work. Do you know anything about that? <BR/>THX in advanceAnonymousnoreply@blogger.com