0

Im struggling with a problem in SharePoint 2013.

I have one list with procedure codes, which includes the “procedure code” plus some other fields In another table, i have volume data related to procedure code. If i in addition to the “procedure code” column in the procedure code list ad a “look-up” field, i can join the data from the two tables in an elegant way. The disadvantage is that the “look-up” field manually have to have the procedure code added there to show the corresponding data.

Is it possible / complicated to make this automatic?

  • You mean when a new item is created, it should pick the lookup field automatically? so the lookup list only have 1 item or am I missing something? – Arsalan Adam Khatri Apr 8 '14 at 15:32
  • the thing is that i have so many things to add, and it would take me so much time if i had to do that. And save so much time if it was possible. I have two lists, one with the lookup field that take a value from the other list. But can i do this automatic? – user24975 Apr 9 '14 at 6:59
  • you might need to write script, either powershell or using client object model.. It isn't possible Out of the box.. One way is Import Spreadsheet as a List.. But that will not place values in two lists and use as lookup.. – Arsalan Adam Khatri Apr 9 '14 at 7:08
  • okej. So you´re that the only way is to write a script with powershell or using client object model? It doesnt have some settings inside SharePoint or it just with script? – user24975 Apr 9 '14 at 7:16
  • AFAIK, no there isn't any setting.. but wait for other experts to look at the question and maybe they can suggest something.. – Arsalan Adam Khatri Apr 9 '14 at 7:20
0

You may be looking for something like:

// Re-bind the lookup column if necessary
                SPFieldLookup lookUp = (SPFieldLookup)taskList.Fields.GetField("RI Item");
                // if the lookup column is looking for a list that no longer exists
                if (!lookUp.LookupList.Equals(riList.ID))
                {
                    // Re-bind it by updating the schema xml of the column
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(lookUp.SchemaXml);
                    XmlAttribute attr = xml.CreateAttribute("List");
                    attr.Value = riList.ID.ToString("B");
                    xml.DocumentElement.SetAttributeNode(attr);

                    lookUp.SchemaXml = xml.InnerXml;
                    lookUp.Update();
                }

Related Links:

http://social.msdn.microsoft.com/Forums/en-US/f5c421a2-ca88-414e-9110-2b8ecb716e54/reattach-a-sharepoint-list-lookup-column-to-the-source-list?forum=sharepointdevelopmentlegacy

Fix a lookup type site column when website is provisioned

http://www.habaneroconsulting.com/insights/How-to-define-a-LookupField-referencing-list-in-another-web.aspx

  • Please mark as answer if it worked for you. Thanks! – Amadeo Gallardo Apr 11 '14 at 13:03

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.