1 关于custom button
调用object以及调用apex:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js" )}
if( '{!Campaign_Plan__c.Campaign_Status__c}' != 'Activated'){
alert('You are not allow to deactivate campaign plan.');
}
else {
var answer = window.confirm ('Are you sure to deactivate current campaign plan?');
alert(answer );
if( answer ){
alert('answer' );
// var campaign = new sforce.SObject("Campaign_Plan__c");
//alert(campaign);
alert('{!Campaign_Plan__c.Id}');
var result = sforce.apex.execute('WD_CampaignPlanUnlock','updateToDraft',{planId :'{!Campaign_Plan__c.Id}'});
alert(result );
window.location.reload();
}
}
2 审批流中的lock和unlock可以使用apex来改变。
需要在setup中,Process Automation Settings中把Enable record locking and unlocking in Apex勾上,不然会报 {faultcode:'soapenv:Client; faultstring:'No such parameter id defined for operation. please check the WSDL for the service.'} 错误。
3.我在写visualforce page的时候用到了button代码如下:
但是在canel方法中如果不使用就会出问题。官方解释:A Boolean value that specifies whether the action associated with this component should happen immediately, without
processing any validation rules associated with the fields on
the page. If set to true, the action happens immediately and
validation rules are skipped. If not specified, this value defaults
to false.在我看来,immediate只会执行action操作,如页面跳转等,不会执行方法里的逻辑操作。
4.with sharing 和 without sharing ,以及默认不声明区别
在salesforce中,声明类大概可以分成三类:分别是可以声明为with sharing,without sharing,以及两者均不声明.
1 public with sharing class A {}
2
3 public without sharing class B{}
4
5 public class C{}
三者区别如下:
总局:具体用哪个形式,看项目需求,如果项目需要可控度高,防止因为salesforce自身的坑而无可奈何,则可以通过without sharing形式,校验自己用apex代码搞定;如果需要salesforce封装的sharing功能进行快速开发,可以通过with sharing。
sharing settings路径:setup->Administer->Security Controls->Sharing Settings。
Difference between Workflows and ProcessBuilder:
ProcessBuilder:Create a record ,
Update any related record ,
Use a quick action to create a record,
update a record, or log a call Launch a flow ,
Send an email Post to Chatter ,
Submit for approval Call apex methods ,
But the process builder doesn’t support outbound messages.
Workflow does only 4 actions :
Create Task ,
Update Field ,
Email Alert ,
Outbound Message.
@TestVisible
Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn’t change the visibility of members if accessed by non-test classes.
With this annotation, you don’t have to change the access modifiers of your methods and member variables to public if you want to access them in a test method. For example, if a private member variable isn’t supposed to be exposed to external classes but it should be accessible by a test method, you can add the TestVisible annotation to the variable definition.
Salesforce has a bunch of rules that can be defined on objects and fields. For example you can define validation rules, workflow rules, assignment rules, escalation rules, auto-response rules, triggers etc.
As an administrator and developer it is important for you to understand the order in which these rules and triggers are executed. Here is the gist of sequence in which Salesforce will evaluate different rules (For detailed explanation, please click here).
(By the way if you are preparing for Advanced Developer Certification i.e. DEV-501, there are a couple of questions on the order of execution)
To remember this sequence you can memorise the following.
SV -> BT -> CV -> AT -> AR -> ARR -> WR (BT, AT) -> ER -> RSFCOF -> CBS -> PCL
update 2021:
On the server, Salesforce:
Salesforce runs custom validation rules if multiline items were created, such as quote line items and opportunity line items.
When a process or flow executes a DML operation, the affected record goes through the save procedure.
官方文档:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm