i have two lists. the first list name is "cases" and the second list name is "issues". in the cases list i have a text column that holds a case number. in the issues list i have lookup column name "connceted case". i want this lookup column to do a lookup against the case number field in the cases list, and to retrieve the values from that field.
I also want to do this: i have a choice column which name is "status" in the cases list. If the value of the status field is "closed" for a specific case item in the cases list, i want to make a restriction that the specific case item with the status of closed, wont be able to chooce in the lookup field connected case.
I dont know where to start, is this possible to do programmatically from visual studio??
Update i have tried the method now. The method adds the column just fine. But something is still wrong with the method, because when i add the method in my feature receiver for the site, it does the jobb for the lookup column, but i dont execute the following methods after the lookup methods. for example: Helpermethods.AddLockup, HelperMethods.CreateQuickLaunch.. it doesnt execute the CreateQuickLaunch
SPList sourceList = web.Lists["cases"];
SPList dependList = web.Lists["issues"];
string lookupColumn = dependList.Fields.AddLookup("connected case", sourceList.ID, true);
SPFieldLookup primaryLookup = (SPFieldLookup)dependList.Fields.GetFieldByInternalName(lookupColumn);
primaryLookup.LookupField = sourceList.Fields["casenumer"].InternalName;
primaryLookup.Indexed = true;
primaryLookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.Restrict;
primaryLookup.Update();
**//Why do i need this secondary column? I have just copy and paste this one from the article. What function does the Last Name field does in my situation?**
string strSecondaryCol = dependList.Fields.AddDependentLookup("Last Name", primaryLookup.Id);
SPFieldLookup secondaryCol = (SPFieldLookup)dependList.Fields.GetFieldByInternalName(strSecondaryCol);
secondaryCol.LookupField = sourceList.Fields["Last Name"].InternalName;
secondaryCol.Update();