0

Is there any way to retrieve the URLs or a least the Names/IDs of all child lists that have lookup columns referencing the parent list in SharePoint. It is easy to find the parent list of a child list by expanding the lookup column with REST but I can't figure out a way to get the child lists of a parent. It seems like this should be possible since SharePoint has an OOTB WebPart to display related lists.

I know it can be done out of the box, but I need a way to retrieve the child lists with client-side code. This is part of a custom solution and I can't use out of the box web parts.

0

We have a workaround solution for your requirement, the lists that has a lookup column in it will definitely be a child list to some parent list in the site. So we may find all the lists in the site that contains lookup column in it.

You may create a console application and include the below code to get the all the lists that has a lookup column.

ClientContext context = new ClientContext(“URL”)
Web web = context.Web;
context.Load(web.Lists);
context.ExecuteQuery();
foreach (List list in web.Lists)
{
    context.Load(list.Fields);
    context.ExecuteQuery();

    foreach (SP.Field field in list.Fields)
    {
        if (field.FieldTypeKind.ToString().Equals("Lookup"))
            Console.WriteLine(list.Title + " has a lookup column: " + field.InternalName);
    }
}
  • Can I do the same thing with javascript and the REST api? – James11 Oct 19 '15 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.