目前,我只能返回一个结果,因为我已经明确指定了我想要返回此行的广告系列:
SELECT Id from campaign WHERE Id = '701i0000000JXz5'
我希望我的页面列出所有将特定字段设置为特定状态的广告系列。当我将上面给出的行更改为:
SELECT Id from campaign WHERE Type = 'Direct Mail'
我收到以下错误:
System.QueryException: List has more than 1 row for assignment to SObject
我所做的是将我的列表限制为一项,但我不确定它是什么。
这是视觉力量页面:
<apex:page standardController="campaign" recordSetVar="dmcampaigns" extensions="DirectMailfilter"> <apex:form >
<apex:pageBlock title="Direct Mail">
<apex:pageBlockTable value="{!dmcampaigns}" var="s">
<apex:column value="{!s.StartDate}"/>
<apex:column value="{!s.Type}"/>
<apex:column value="{!s.status}"/>
<apex:column value="{!s.Name}"/>
</apex:pageBlockTable>
</apex:pageBlock> </apex:form> </apex:page>
使用此扩展名:
public class DirectMailfilter {
public id camRecId;
public DirectMailfilter(ApexPages.StandardsetController controller) {
camRecId = [SELECT Id from campaign WHERE Id = '701i0000000JXz5'].id;
}
List<campaign> dmcampaigns;
public List<campaign> getdmcampaigns() {
if(camRecId != null) {
dmcampaigns= [SELECT StartDate, Type, Status, Name
FROM Campaign
WHERE campaign.id=:camRecId];
}
return dmcampaigns;
}
}