保存时salesforce中的查找字段为空 [英] Lookup field in salesforce is null when saving
问题描述
我在使用标准查找字段时遇到问题.当我尝试保存它时,当我使用自动完成功能或仅输入名称时,它的值为 null,但当我通过单击查找图标使用查找弹出窗口时它会起作用.
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;
}
}
查看:
<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>
dummyObject 是一个具有几个查找字段的对象.(Contact_c to Contact, Account_c to Account, etc...)
The dummyObject is an Object that has a couple of lookup fields. (Contact_c to Contact, Account_c to Account, etc...)
我实际上并没有保存它.但是当你 system.debug 它时它不应该是 null...
I am not actually saving it. But it should not be null when you system.debug it...
推荐答案
我终于找到了问题所在.这是一个已知问题,我认为是一个非常严重的错误.为联系人使用输入字段时,如果名字字段或姓氏字段中有空格,则会出错.
I finally found out what the problem is. It is a known issue that I consider to be a very serious bug. When using an inputfield for a contact, it goes wrong when you have a space in either the firstname field or the lastname field.
知识文章编号:000123565
Knowledge Article Number: 000123565
这篇关于保存时salesforce中的查找字段为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!