I have a SharePoint list with a lookup field, is it possible to change the target list fro UI? I don't have access to Powershell
Any thoughts how I could change the field without delete?
Unfortunately, There is no way to change the Get Information
list of Lookup field through UI.
The available options are
You can test out the below JSOM code in a Content Editor Webpart. I have tested and it successfully changes the lookup list. But you will have to do further testing to ensure that nothing else is broken. This code directly changes the list field schema from client side which is not really a good approach as even the slightest error can make the list useless. Suggested approach would still be PowerShell Or Field Recreation.
The parameters :
fromList - Current List where look up field is present
fromField - LookUp field name
toListId - The New LookUp List guid which you can get as mentioned here
<script language="javascript" type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
SP.SOD.executeOrDelayUntilScriptLoaded(updateWebSite, "sp.js");
});
var oWebsite ;
function updateWebSite() {
var fromList = 'Check List';
var fromField = 'LookUpColumn';
var toListId = '{82b5a10b-f263-4b69-a67b-105d73dce817}';
var ctx = new SP.ClientContext();
var field = ctx.get_web().get_lists().getByTitle(fromList).get_fields().getByInternalNameOrTitle(fromField);
ctx.load(field);
ctx.executeQueryAsync(function() {
var schema = field.get_schemaXml();
schema = schema.replace(/list=\"\S*\"/i, '').replace(/\/\>/, 'List="' + toListId + '" />');
field.set_schemaXml(schema);
ctx.executeQueryAsync();
});
}
</script>
The above code changed the look up list from Approval List to Accordion
After running the script :