Salesforce 超过最大视图状态大小限制(135KB)
多年来,该代码一直运行良好Salesforce 超过最大视图状态大小限制(135KB),salesforce,visualforce,apex,Salesforce,Visualforce,Apex,多年来,该代码一直运行良好 public PageReference chkinst() { i=0; integer j=0; Set<String> aSearchSet = new Set<String>(); List<Lead> lList = ui; for (Lead l : lList) { aSearchSet.add(l.company)
public PageReference chkinst() {
i=0;
integer j=0;
Set<String> aSearchSet = new Set<String>();
List<Lead> lList = ui;
for (Lead l : lList) {
aSearchSet.add(l.company);
}
Account[] accountToCreate = new Account[]{};
Map<String,Account> companyToAccountMap = new Map<String,Account> ();
for (Account a: [select id, Name from Account where name IN :aSearchSet])
companyToAccountMap.put(a.name,a);
for (Lead l : lList) {
if (!companyToAccountMap.containsKey(l.company)){
Account act = new Account(Name = l.Company , Country__c = l.Country__c );
accountToCreate.add(act);
j = j +1;
}
}
insert accountToCreate;
if(j == 0) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'All leads have correct institution names'));
} else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,j + ' Institutions created'));
}
return null;
}
今天,它给了我以下错误:
超过最大视图状态大小限制135KB。此页面的实际视图状态大小为135.078KB
有人知道为什么吗
谢谢,很难从这段代码中分辨出来。但如果非要我猜的话。看起来您的companyToAccountMap是一个类级变量,它现在可能返回的记录比以前多。如果您不需要控制器中其他任何位置的映射,我会将其移动到方法级别或使其暂时化