0

here's the code

    using (SPSite site = new SPSite("https://mysite.com/Ting/default.aspx"))
    {
        using (SPWeb web = site.OpenWeb())
        {
            SPList SourceList = web.Lists["Record1"];
            SPList TargetList = web.Lists["Record2"];

            SourceList.Fields.AddLookup("Certificate", TargetList.ID, false);
            SPFieldLookup lkp = (SPFieldLookup)SourceList.Fields["Certificate"];

            lkp.LookupField = TargetList.Fields["Name"].InternalName;
            lkp.Update();

            for (int i = 0; i < 3; i++)
            {
                SPView view = SourceList.Views[i];
                view.ViewFields.Add("Certificate");
                view.Update();
            }
        }
    }

what I am doing here is creating a lookup field in a already created Sharepoint list, Problem is, when I add a to Source List, it shows me all the certificates in a drop down choice, but when i see all the items view, it shows certificate names as " 1_.000" and increment by the number of items i add to the list, even if i use same certificate.

sounds like a logical problem to me :/

1 Answer 1

0

The Reason was because, both Sharepoint builtin Forms were calling different attributes of the lookup field.

In order to finish my task, i created a event handler that, copies name field to Title field, so that later on i can use it.

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.