I've currently got a new task list item for a certain content type (DMR) which fails to take through the lookup to the associated list. The statement prints the correct record number in the immediates window but doesn't take the value through. The task list has the newly created item available as a lookup on edit so I'm confused as to what the problem is as all other fields are set when the code is executed.
Here's the coding:
//gets the current list item
SPListItem oCurrent = properties.ListItem;
//create a new task containing a lookup to the current item
SPList olstRegisterTasks = oCurrent.Web.Lists["Register Tasks"];
SPListItem oTask = olstRegisterTasks.Items.Add();
//other fields that work as aspected..
//the next line doesn't assign
oTask["Related DMR"] = new SPFieldLookupValue(oCurrent["DMR No."].ToString()).LookupId;
oTask.Update();