I have a problem with a standard lookup field. When I try to save it, it has value null when I use autocomplete or just type the name but it works when I use the lookup popup by clicking the lookup-icon.
This is (part of) the code. (Not all of it, but even this simple controller and page doesn't work...) Controller:
public with sharing class UnresolvedItemsController {
public list<TaskItem> myUnresolvedTaskItems {get;set;}
public class TaskItem {
public string taskId {get;set;}
public string subject {get;set;}
public datetime createdDate {get;set;}
public DummyObject__c dumObj {get;set;}
}
public UnresolvedItemsController(ApexPages.Standardcontroller controller) {
if (myUnresolvedTaskItems==null) {
myUnresolvedTaskItems = new list<TaskItem>();
list<Task> myUnresolvedTasks = [select id,subject,createdDate,Description from Task Where Status='Not Started' and isDeleted=false and isClosed=false and isArchived=false and OwnerId=:UserInfo.getUserId() and subject like 'Unresolved Email:%' limit 10];
TaskItem tmp = new TaskItem();
for (task myT:myUnresolvedTasks) {
myUnresolvedTaskItems.add(getInfoFromTask(myT));
}
}
}
public TaskItem getInfoFromTask(Task myTask) {
TaskItem returnTaskItem = new TaskItem();
returnTaskItem.subject = myTask.Subject.replace('Unresolved Email: ','');
returnTaskItem.createdDate = myTask.createdDate;
returnTaskItem.taskId = myTask.Id;
returnTaskItem.dumObj = new DummyObject__c();
return returnTaskItem;
}
public pagereference save() {
system.debug('1-----'+myUnresolvedTaskItems);
return null;
}
}
View:
<apex:page standardcontroller="Task" extensions="UnresolvedItemsController">
<apex:form >
<apex:pageblock >
<apex:pageblockbuttons >
<apex:commandbutton action="{!Save}" value="{!$Label.Save}" />
<apex:commandbutton action="{!Cancel}" value="{!$Label.Cancel}" />
</apex:pageblockbuttons>
<apex:pageblocktable value="{!myUnresolvedTaskItems}" var="ti">
<apex:column >
<apex:facet name="header">Subject</apex:facet>
<a href="/{!ti.taskId}">{!ti.subject}</a>
</apex:column>
<apex:column >
<apex:facet name="header">Date</apex:facet>
{!ti.createdDate}
</apex:column>
<apex:column >
<apex:facet name="header">Assign to salesforce.com objects</apex:facet>
<apex:inputfield value="{!ti.dumObj.Contact__c}" />
</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>
The dummyObject is an Object that has a couple of lookup fields. (Contact_c to Contact, Account_c to Account, etc...)
I am not actually saving it. But it should not be null when you system.debug it...