Editing Filtered Lookup field definition

Dec 3, 2013 at 4:56 PM
Hi

Does anyone know if there a quick way to edit a filtered lookup field and amend properties after it's been created and used for a while? I want to edit the "Get Information From this site" field because we've had to archive an old site being used as a source and replace with another. Only the new site will receive updates, so ideally we'd like to point some of our filtered lookup fields in other sites to this new site.

Many thanks for any help.
Jan 8, 2014 at 7:10 PM
You can edit the "pointers" of a filtered lookup field using the SharePoint Object model. Here's a Powershell script snippet:
# Update the directly-accessible values of the filtered lookup field.

    $field.LookupField = $targetFieldId
    $field.Update()
    $field.LookupWebId = $targetWebId
    $field.Update()
    $field.ListViewFilter = $targetViewId
    $field.Update()
where $targetFieldId is the ID of the target field, $targetWebId is the ID of the target web site and $targetViewId is the ID of the target View (assuming you are using View Filtering). Notice that this snippet does not update the targetListId, even though there is a SPField property for this value. The SharePoint implementation of lookup fields blocks the direct update of this field, so this must be done by updating the $field.SchemaXML value.