Salesforce Platform Developer I 補(bǔ)充

Trigger Conext

Variable Usage
isExecuting Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call.
isInsert Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API.
isUpdate Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.
isDelete Returns true if this trigger was fired due to a delete operation, from the Salesforce user interface, Apex, or the API.
isBefore Returns true if this trigger was fired before any record was saved.
isAfter Returns true if this trigger was fired after all records were saved.
isUndelete Returns true if this trigger was fired after a record is recovered from the Recycle Bin (that is, after an undelete operation from the Salesforce user interface, Apex, or the API.)
new Returns a list of the new versions of the sObject records.
This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
newMap A map of IDs to the new versions of the sObject records.
This map is only available in before update, after insert, after update, and after undelete triggers.
old Returns a list of the old versions of the sObject records.
This sObject list is only available in update and delete triggers.
oldMap A map of IDs to the old versions of the sObject records.
This map is only available in update and delete triggers.
size The total number of records in a trigger invocation, both old and new.

Custom Controller & Controller Extension

A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.

A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:
You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
You want to add new actions.
You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it **executes in user mode
**, in which permissions, field-level security, and sharing rules of the current user apply.

Custom Exception:

To create your custom exception class, extend the built-in Exception class and make sure your class name ends with the word Exception.

Success message

For Create a Record, Update a Record, and Log a Call action types, you can create a custom message that displays when the action executes successfully.


success message

Interface

Interface methods have no access modifiers. They are always global. ... This is the default, and means that the method or variable is accessible only within the Apex class in which it is defined. If you do not specify an access modifier, the method or variable is private .

StandardController

You can instantiate a StandardController in the following way:
ApexPages.StandardController sc = new ApexPages.StandardController(sObject);

StandardController Methods

The following are methods for StandardController. All are instance methods.

  • addFields(fieldNames)
    When a Visualforce page is loaded, the fields accessible to the page are based on the fields referenced in the Visualforce mark up. This method adds a reference to each field specified in fieldNames so that the controller can explicitly access those fields as well.
  • cancel()
    Returns the PageReference of the cancel page.
  • delete()
    Deletes record and returns the PageReference of the delete page.
  • edit()
    Returns the PageReference of the standard edit page.
  • getId()
    Returns the ID of the record that is currently in context, based on the value of the id query string parameter in the Visualforce page URL.
  • getRecord()
    Returns the record that is currently in context, based on the value of the id query string parameter in the Visualforce page URL.
  • reset()
    Forces the controller to reacquire access to newly referenced fields. Any changes made to the record prior to this method call are discarded.
  • save()
    Saves changes and returns the updated PageReference.
  • view()
    Returns the PageReference object of the standard detail page.

Overriding Buttons, Links, and Tabs with Visualforce

You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab.

To override a standard button or a tab home page:

  1. Click Edit next to the button or tab home page you want to override.
  2. Pick Visualforce page as an override type.
    Select the Visualforce page you want to run when users click the button or tab.
  3. When overriding buttons with a Visualforce page, you must use the standard controller for the object on which the button appears.
    • Use a controller extension when you need to add extra functionality to Visualforce page that you are using as an override.
  4. Save

Setter Method

Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.
While a getter method is always required to access values from a controller, it’s not always necessary to include a setter method to pass values into a controller. If a Visualforce component is bound to an sObject that is stored in a controller, the sObject's fields are automatically set if changed by the user, as long as the sObject is saved or updated by a corresponding action method.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請(qǐng)通過(guò)簡(jiǎn)信或評(píng)論聯(lián)系作者僚楞。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市拾因,隨后出現(xiàn)的幾起案子媒吗,更是在濱河造成了極大的恐慌,老刑警劉巖抑堡,帶你破解...
    沈念sama閱讀 211,194評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件涌矢,死亡現(xiàn)場(chǎng)離奇詭異掖举,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)娜庇,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,058評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門塔次,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人思灌,你說(shuō)我怎么就攤上這事俺叭。” “怎么了泰偿?”我有些...
    開封第一講書人閱讀 156,780評(píng)論 0 346
  • 文/不壞的土叔 我叫張陵熄守,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我耗跛,道長(zhǎng)裕照,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,388評(píng)論 1 283
  • 正文 為了忘掉前任调塌,我火速辦了婚禮晋南,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘羔砾。我一直安慰自己负间,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,430評(píng)論 5 384
  • 文/花漫 我一把揭開白布姜凄。 她就那樣靜靜地躺著政溃,像睡著了一般。 火紅的嫁衣襯著肌膚如雪态秧。 梳的紋絲不亂的頭發(fā)上董虱,一...
    開封第一講書人閱讀 49,764評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼愤诱。 笑死云头,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的淫半。 我是一名探鬼主播溃槐,決...
    沈念sama閱讀 38,907評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼撮慨!你這毒婦竟也來(lái)了竿痰?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,679評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤砌溺,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后变隔,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體规伐,經(jīng)...
    沈念sama閱讀 44,122評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,459評(píng)論 2 325
  • 正文 我和宋清朗相戀三年匣缘,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了猖闪。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,605評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡肌厨,死狀恐怖培慌,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情柑爸,我是刑警寧澤吵护,帶...
    沈念sama閱讀 34,270評(píng)論 4 329
  • 正文 年R本政府宣布,位于F島的核電站表鳍,受9級(jí)特大地震影響馅而,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜譬圣,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,867評(píng)論 3 312
  • 文/蒙蒙 一瓮恭、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧厘熟,春花似錦屯蹦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,734評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至就缆,卻和暖如春帖渠,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背竭宰。 一陣腳步聲響...
    開封第一講書人閱讀 31,961評(píng)論 1 265
  • 我被黑心中介騙來(lái)泰國(guó)打工空郊, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留份招,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,297評(píng)論 2 360
  • 正文 我出身青樓狞甚,卻偏偏與公主長(zhǎng)得像锁摔,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子哼审,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,472評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容