Showing posts with label CSOM. Show all posts
Showing posts with label CSOM. Show all posts

Wednesday, July 8, 2015

Provision additional lookup fields with CSOM

When you create a lookup field in SharePoint, you’ll have the option to add additional fields of the source list to your target list. When you create this from the UI, you check those fields on creation of the lookup field. But when you create this from your provision code, you can’t find any parameters on the lookup field itself.

The key for doing this in the code is the method AddDependentLookup on the Fields collection of the target list. To provision this lookup, I created the following method in my provisioner:

Please note that the lookupFieldId should be the fieldId of the field you want to add to your target list, and there should be another ‘primary’ lookup field configured between the two lists. The displayName is free to choose, this one will show up as column heading for instance in your target list.

Wednesday, February 19, 2014

Quickly update WebPart titles by CSOM

While entering content for a new SharePoint section on a SharePoint 2010 publishing site, the content editors added a related articles webpart on about 100 pages. Too bad they didn't bother to change the webpart title, so I was asked to change change these titles, which had their default value, from a rather functional description of the webpart to something that makes a lot more sense in on the pages. As it should be possible to do it in CSOM, I created a small console application to achieve this.