Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Pushing site lookup column specific changes to lists

$
0
0

Hi,

For quite some time I was wondering, how do you push lookup column LookupList and LookupWebId values to list without altering other list column attributes? Let me explain. We have couple site level lookup columns that are used in several list. Some of these list requires a default value to be specified but it varies by list so I can't specify it at site column. Also I want to enforce relationship restrictions which is only possible with list column.

Here is example of my site level column definition:

<Field ID="{c5762f67-b63d-45d3-8670-25047e789945}" Name="MyColumn" DisplayName="MyColumn" Type="Lookup" List="Lists/MyList1" ShowField="Title" Required="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" Group="MyGroup"></Field>

Here is same column in a list:

<Field ID="{c5762f67-b63d-45d3-8670-25047e789945}"
             Name="MyColumn"
             DisplayName="MyColumn"
             Type="Lookup"
             List="Lists/MyList1"
             ShowField="Title"
             Required="FALSE"
             Indexed="TRUE"
             RelationshipDeleteBehavior="Restrict"
             SourceID="http://schemas.microsoft.com/sharepoint/v3"
             Group="MyGroup"><Default>3</Default></Field>

Now during feature activation I update site column like this:

  • Change lookup list from relative url to guid.
  • Add WebId attribute with appropriate web id.
  • Call update with push to lists set to true.

While this works it has some side effects. Now my list column doesn't have default value and relationship behavior is also missing.

I could do manual updating for these couple of list columns but I was wondering maybe it's possible to do in somewhat cleaner and more elegant way?


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>