【发布时间】:2015-05-03 17:59:15
【问题描述】:
我正在尝试通过一些修改来运行它。 http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/
我必须获取我的联系人具有联系人角色的帐户及其所属的帐户。
我已经编写了 soql 查询并且有来自两个对象的不同帐户。 我将列表保存为设置以避免重复。
我的第二个 vf 页面显示帐户名称,但是当我选择帐户名称时,在我的第一个 vf 页面中出现此错误。
错误:值“{!Cas.AccountId}”不是有效的 id 字段 是的,因为我正在添加值以设置为 set.add(variable.name); 这将显示帐户名称..如果我添加 ids,它会在用户无法理解的 vf 页面上显示 ids。
我被击中了,不能进去!!! 请指导我!!!!!!
先谢谢了!!!!!! 我的第二个 vf 页面和课程
<apex:page controller="Customaccountlookupcontroller" tabStyle="Account" showHeader="false" title="Search" id="pg" sidebar="false">
<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">
<!-- SEARCH TAB -->
<apex:tab label="Search" name="tab1" id="tabOne">
<apex:actionRegion >
<apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}" />
<span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
</apex:outputPanel>
<apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
<apex:pageBlock id="searchResults">
<apex:pageBlockTable value="{!allaccts}" var="a">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Account Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a}','{!a})', false)" rendered="{!NOT(ISNULL(a))}">{!a}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>
</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
</apex:page>
顶级类:
Public with sharing class Customaccountlookupcontroller{
Public set<string> allaccts{get;set;}
public string searchString{get;set;}
Public list<account> results{get;set;}
Public string selectedkey{get;set;}
public Customaccountlookupcontroller() {
allaccts = new set<string>();
//Contact objcontact =[select accountid,(select AccountId,Account.name from AccountContactRoles) from Contact where id=:userList[0].contactId];
Contact objContact =[select AccountId,Account.name,(select AccountId,account.name from AccountContactRoles) from Contact where Id='00317000006VtoR'];
for(AccountContactRole obj: objContact.AccountContactRoles)
{
allaccts.add(obj.account.name);
allaccts.add(objContact.account.name);
}
System.debug('*******objcontact:'+allaccts);
}
public PageReference search() {
return null;
}
}
public string getFormTag() {
return System.currentPageReference().getParameters().get('frm');
}
public string getTextBox() {
return System.currentPageReference().getParameters().get('txt');
}
}
【问题讨论】:
标签: set salesforce lookup apex