40、【Skinny Table限制 - 不支持多个对象,最多支持100个字段】:
目的:可请求Salesforce Support为常用字段创建Skinny Table,用于提升Report和SOQL的性能;
特征:1. 记录不包含软删除;2. 通过减少table joins提升性能;3. 查出的记录总是最新的 (与base object实时同步);
39、【Custom Label限制 - 5000/org】:Custom Labels
You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length. Custom labels from managed packages don’t count toward this limit.
For Categories used for list view, the total number of characters allowed in the Categories text box is 255.
38、【Multi-Level Navigation Menu层级限制 - 5】:Multi-Level Navigation Menu
The Multi-Level Navigation Menu component is available in all templates. But it’s meant for use only in the B2B Commerce template or when you’re adding B2B functionality to another template. The component shows five menu levels only when you use it with product categories.
37、【Lightning Community Navigation Menu Items限制 - 20】:Navigation Menu
You can add up to 20 navigation menu items.
36、【Email Alerts每日限制】:Daily Allocations for Email Alerts - 24-hour period starting and ending at midnight GMT
a. 限量计算:The daily allocation for emails sent through email alerts is 1,000 per standard Salesforce license per org. The overall org allocation is 2,000,000. - 假如付费org购买了15个salesforce full license,配额是:15 x 1000,无论购买多少full license,上限为200万;
b. 适用范围:通过workflow,process builder,flow,approval process,rest api发送Email;
c. 超限后sf默认行为:以总限制1000举例
1)如果已用990,当天通过各渠道发Email峰值为20,那么后面10个将被放弃,sf不会让队列里的邮件在第二天重新发送 ;
2)If a workflow rule with an action and an email alert is triggered, only the email action is blocked.
3)Final approval, final rejection, approval, rejection, and recall email actions are blocked. - 关于Approval Process的Email Alert仅初始化提交的Email Alert不被计入限制;
4)An error message is added to the debug log.
d. 不列入每日限制项:
- Approval notification emails - 指审批提交邮件通知;
- Task assignment notifications - 分配Task启用Email通知,或Apex创建Task使用notifyOption.EmailHeader.triggerUserEmail = true发送的邮件;
- Lead / Case assignment rules notifications
- Case escalation rules notifications
- Salesforce Sites usage alerts
e. 注意事项:
1) 增加或移除Salesforce Full License立即调整配额;
2)Each org can send single emails to a maximum of 5,000 external email addresses per day.
3)There’s no limit on sending single emails to contacts, leads, person accounts, and users in your org directly from account, contact, lead, opportunity, case, campaign, or custom object pages.
4)When workflow email alerts approach or exceed certain allocations, Salesforce sends a warning email to the default workflow user or—if the default workflow user isn't set—to an active system administrator.
35、【一个事务中DML最多处理10000条记录】:比如insert 10000, 紧接着update 10000报错:20000 > 10000
public static void limitTest() {
List<Test__c> testList = new List<Test__c>();
for(Integer i = 0 ; i < 10000; i ++) {
testList.add(new Test__c(
Name = 'Test'+i
));
}
System.debug(LoggingLevel.INFO, '*** testList size: ' + testList.size());
insert testList;
for(Test__c t : testList) {
t.Required_Text__c = '1';
}
update testList;
}
思考:假如Apex Batch每天需要Convert 20000条Lead(每次批处理100,在Finish方法中完成)到存在的Contact,同时在Trigger里面需要基于已转化的Lead将Related List关联到Converted Contact,Transfer Related List时用的是Database.update(List<Sobject> objList, false)泛型处理,如果相关列表项有3个(为自定义),每个Lead对应的相关列表项最多5条记录,查询时用到的是父查子模式,请问Trigger中每个事务中的SOQL和DML会超出限制吗?
解答:不会。
Trigger中每个事务中的SOQL和DML统计如下:
SOQL:(3 x 5 + 1) x 100 = 1600 < 50001;
DML:3 x 5 x 100 = 1500 < 10001;
34、【Mass Email Limitations】:Mass Email Limitations | Daily Allocations for Email Alerts
You can send mass email to a maximum of 5,000 external email addresses per day per org based on Greenwich Mean Time (GMT).
The following limitations also apply to mass emails.
- The single and mass email limits don't take unique addresses into account. For example, if you have johndoe@example.com in your email 10 times, that counts as 10 against the limit. 同个地址包含在10个email中,计算10次
- You can send an unlimited amount of email to your org’s internal users, which includes portal users. 发email给internal / portal user无限制
- You can send mass emails only to contacts, person accounts, leads, and your org’s internal users.
- In Developer Edition orgs and orgs evaluating Salesforce during a trial period, you can send mass email to no more than 10 external email addresses per day. This lower limit doesn’t apply if your org already had mass email enabled with a higher limit. Also, your org can send single emails to a maximum of 15 email addresses per day.
- You can’t send a mass email using a Visualforce email template.
33、【Apex code最大限制为6MB】:
One advantage to creating a separate class for testing is that classes defined with isTest don’t count against your org’s limit of 6 MB of Apex code. You can also add the @isTest annotation to individual methods.
32、【List controllers are not supported for Task】:Idea Link | Custom List Controller for Task
31、【convertLead功能一次最多处理100条记录 - 解决方案】:Bulk Lead convert 200 leads at a time: Is it possible?
public static void massLeadConvert(Map<Id, String> lid2AccAndContidMap, Map<Id, List<Id>> master2DupMap) {
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
List<String> errList = new List<String>();
for(Id s : lid2AccAndContidMap.keySet()) {
List<String> valst = lid2AccAndContidMap.get(s).split(DELIMITER);
leadConverts.add(getLeadConvert(s, valst[0], valst[1]));
}
// Max 100 records for convertLead limitation
for(Integer i = 0; i <= leadConverts.size()/100 ; i++){
list<Database.LeadConvert> tempList = new list<Database.LeadConvert>();
Integer startIndex = i*100,
endIndex = ((startIndex + 100) < leadConverts.size()) ? startIndex + 100 : leadConverts.size();
for(Integer j = startIndex; j < endIndex; j++)
tempList.add(leadConverts[j]);
// Execute the conversions and check for success.
List<Database.LeadConvertResult> results = Database.convertLead(tempList, false);// allow partial success.
handleConvertResult(tempList, results, master2DupMap, errList);
}
if(master2DupMap.size() > 0) markDuplicatWith(master2DupMap);
if(errList.size() > 0) IMS_Utility.bulkSaveLogs(errList);
}
public static void handleConvertResult(List<Database.LeadConvert> tempList, List<Database.LeadConvertResult> results, Map<Id, List<Id>> master2DupMap, List<String> errList) {
for(Integer k = 0; k < tempList.size(); k++) {
Database.LeadConvertResult result = results[k];
Database.LeadConvert sobj = tempList[k];
if(!result.isSuccess()) {
Id conid = sobj.getContactId();
master2DupMap.remove(conid);
errList.add(handleErrorMsg(result.getErrors(), sobj.getLeadId(), sobj.getAccountId(), conid));
}
}
}
30、【Continuation Class异步Callout不计次数,最多5s】:
Continuation class in apex can be used to make callout asynchronously to a SOAP or REST Web service from a VF page or Lightning Component.
Such asynchronous requests don't count toward the Apex limit of 10 synchronous requests that last longer then five seconds.
29、【Apex heap size同步事务6MB,异步事务12MB】:
When too much data is being stored in the memory, it can cause the code to exceed the heap size limit, which returns the "Apex heap size too large".
28、【Partner Community自定定义对象10个限制】:
The limit is 10 custom objects per profile per community. There is no technical limit in place here AFAIK, it is a contractual limit so you may get a call from your Salesforce Account Executive at some point.
我们在使用过程中明显超限,依然能正常使用。
27、【Mass Email 24h限制】:企业版本500/d
26、【SOSL搜索字符长度必须大于1】:
search term must be longer than one character
25、【Trigger递归深度限制16】:Execution Governors and Limits
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements is 16
24、【View State 170k限制】:'Maximum view state size limit (170KB) exceeded' error message
23、【标准字段历史跟踪有效期为18月,最多跟蹤20個字段】:FAT<Field Audit Tracking Limitaion>
限制条款:一旦字段历史跟踪达到了18月限制,sf会提供Data Loader / API(Query All)来让你继续访问历史跟踪数据,最多延期6个月,共计24个月。
解决方案:购买FAT add-on license, sf可以保存历史数据最多10年。
22、【自定义对象对象参考 个数限制 - 15】:公式字段
Solution: 提Case扩展Limit | 官方文档
21. 【Sandbox Licenses and Storage by Type】: Link
20. 【List View展示的最大列数为15个】:
19. 【Recycle Bin最多保存删除的数据15天】:remain 15 days
18. 【1个Custom Report Type最多添加4个相关对象】:最多3个子对象
另外Custom Report Type最多支持1000个字段和60个字段参考;
17. 【Home Page上最多显示3个Dashboard Snapshots】:Salesforce Report & Dashboard进阶篇 - 原理浅析
16. 【Import Wizards与Data Loader比较】:When to Use Data Loader
1. Import Wizard -> import up to 5w records;
2. Data Loader -> up to 500w(5 million) records;
3. work with a Salesforce partner or visit the AppExchange for a suitable partner product -> for more than 500w records.
15. 【database.query与database.getQueryLocator】:
database.query in Salesforce: dynamic SOQL query. You can build up a string and then use that as a query string at run time in the database.query statement to make a SOQL call that is determined at run time. In Batch Apex, if you use Database.query(), it supports 50,000 records only.
database.getQueryLocator in Salesforce returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in batch apex or used for displaying large sets in VF (allowing things such as pagination). In Batch Apex, if you use Database.getQueryLocator(), it supports upto 50 million records.
14. 【字段集Field Set Limitation: The total number of spans in the Field Set can't exceed 25】
13. 【child-to-parent soql最多5级查询】:
Exp: Contact.Account.Owner.FirstName(5 levels).
12. 【parent-to-child soql最多只能嵌套1级子查询】
11. 【You can add up to 300 fields per custom setting】
10. 【调试日志记录最大250M,超出时需要手动删除】
9. 【25 ExternalIDs are allowed per object】:Maximum number of External IDs per object or entity
8. 【The maximum size of email attachment is 3 MB when using attach file in a custom email】:
Attach a file to an email template | Send Emails With Attachment in code
7. 【Apex Limits】:Salesforce_app_limits_cheatsheet
Salesforce Governor Limits:
As you aware that, Salesforce is multitenant platform. Multitenant is a software architecture in which a single instance of software runs on a server and serves multiple user groups. Group of users who share a common access with specific privileges to the software instance.
Governor execution limits ensure the efficient use of resources on the Force.com multitenant platform. Because Apex runs in a multitenant environment, the Apex runtime engine strictly enforces limits to ensure that runaway Apex code or processes don’t monopolize shared resources. If some Apex code ever exceeds a limit, the associated governor issues a runtime exception that cannot be handled.
The Apex limits, or governors, track and enforce the statistics outlined in the following tables and sections.
- Per-Transaction Apex Limits
- Per-Transaction Certified Managed Package Limits
- Force.com Platform Apex Limits
- Static Apex Limits
- Size-Specific Apex Limits
- Miscellaneous Apex Limits
In this blog, I have added few of the Governer Limits mentioned below:
1. Total number of SOQL queries issued: 此处实指Query 101
- Synchronous Limit = 100
- Asynchronous Limit = 200
2. Total number of records retrieved by SOQL queries : 50,000
【父查子情况下SOQL查询的限制计算Sample】:
a. 假设我们有50000条Account,然后在其中一条单子下创建一个Contact记录;
b. 为增强Demo效果,我们对Account加上Limit 50000的限制,整个Soql如下所示:
List<Account> accList = [SELECT Id, (SELECT Id FROM Contacts) FROM Account LIMIT 50000];
c.经过匿名执行的验证,我们观察到下图效果:
d. 结论:soql查询不仅仅受限于查询主体的数目,还得考虑所有相关的查询记录数;
【子查父情况下SOQL查询的限制计算Sample】:
a. 假设我们有50001条Account,然后我们将第一条Account设定为最后一条单子的Parent Account;
b. 同样的,我们对Account查询主体加上Limit 50000的限制,整个Soql如下所示:
List<Account> accList = [SELECT Id, Parent.Id FROM Account LIMIT 50000];
c. 最终执行的结果是返回50000条Account,没有超限;
【最终结论】:
我们通过对比上述科学验证的结果发现,父查子增加的实际是行,而子查父实际增加的是列,所以行限制精确表述的魅力亦在于此;
3. Total number of records retrieved by Database.getQueryLocator : 10,000
4. Total number of SOSL queries issued : 20
5. Total number of records retrieved by a single SOSL query : 2,000
6. Total number of DML statements issued : 150
7. Total number of callouts : 100 (include Web Service and HTTP Request calls in a transaction)
【最新理解】:
以上程序有效控制住了Per-Transaction Apex Limits,由此可见异步方法每调用一次单独开一个新事务;
8. Maximum timeout for all callouts: 120s or 2 min (include Web Service and HTTP Request calls in a transaction)
9. Maximum number of @future annotation methods allowed : 50
【测试如下】:
10. Maximum number of Apex jobs added to the queue with System.enqueueJob : 50
11. Total number of sendEmail methods allowed : 10
12. Total heap size : 6 MB or 12 MB
13. Maximum execution time for each Apex transaction: 10 min -> i.e. For Update
14. Maximum number of push notification method calls allowed per Apex transaction : 10
15. Maximum number of push notifications that can be sent in each push notification method call : 2,000
16. Email services heap size is 36 MB.
17. The maximum number of asynchronous Apex method executions per a 24-hour period : 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.
18. Maximum number of Apex classes scheduled concurrently : 100
19. Maximum number of batch Apex jobs in the Apex flex queue that are in Holding status : 100
20. Maximum number of batch Apex jobs queued or active concurrently : 5
21. Event Reports : The maximum number of records that an event report returns for a user who is not a system administrator is 20,000; for system administrators, 100,000.
22. Inbound Email Services: Maximum Number of Email Messages Processed : Number of user licenses multiplied by 1,000; maximum 1,000,000
23. Inbound Email Services: Maximum Size of Email Message : 10 MB
24. Maximum CPU time on the Salesforce servers: 10s (sync limit) and 60s (async limit)
There are some Size-Specific Apex Limits. Check below:
1. Maximum number of characters for a class : 1 million
2. Maximum number of characters for a trigger : 1 million
3. Maximum amount of code used by all Apex code in an organization : 3 MB
4. Method size limit : 65,535 bytecode instructions in compiled form
6. 【up to 10 Apex sharing reasons per custom object】Salesforce Apex Sharing Reason
Note: Sharing reason just exist in Custom Object not in Std Object.
5. 【Multi-Picklist的可见行不能超过10个】
4. 【字段历史跟踪Field History Track的最大个数为20】
Note: 超出后提Case不能额外加,可以联系业务经理按需购买。
3. 【Per object最多2个Master-detail field】
Lookup VS Master-Detail
2. 【Per object最多25个Lookup field】
1. 【Picklist值不能超过1000 / Multi-Picklist值不能超过500】:当然你可以通过提Case要求开放阈值