i have two lists(Invoice & Client) which i had created dynamically through code and i want to create lookup field programmatically for relationship between this two list.
In Invoice List i have following columns:
3.ClientId - this column i need to create as lookup
4.ClientId:ClientName - this column is used to get ClientName from Client List when i enter ID in ClientId Column
In Client List i have following columns:
So far i'm able to create lookfield that is ClientId in invoice list 3rd column but how can i create programmatically 4th column has additional column.
When we create lookup column using sharepoint administration there is an option called "Add a column to show each of these additional fields" this i want to create programmatically
List refList= webobj.Lists.GetByTitle(Constants.Client); clientContext.Load(refList); clientContext.ExecuteQuery(); Field LookUpField = listObj.Fields.AddFieldAsXml( "<Field Type='Lookup' DisplayName='ClientId' Required='FALSE' List='" + refList.Id + "' ShowField='ID' StaticName='ClientId' Name='ClientId' />", true,AddFieldOptions.DefaultValue); LookUpField.Update(); clientContext.ExecuteQuery();