This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MixedDMLFuture { | |
public static void useFutureMethod() { | |
// First DML operation | |
Account a = new Account(Name='Acme'); | |
insert a; | |
// This next operation (insert a user with a role) | |
// can't be mixed with the previous insert unless | |
// it is within a future method. | |
// Call future method to insert a user with a role. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List articles = [SELECT Id FROM knowledge__kav | |
WHERE PublishStatus='Online' | |
AND Language='en_US' | |
AND Id='ka4q000000005rpAAA']; | |
SearchPromotionRule s = new SearchPromotionRule(Query='Trailblazer', | |
PromotedEntityId=articles[0].Id); | |
insert s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var searchterm='ACME Corporation'; //text to search for | |
//this is the decoded base64 string from the global search url | |
var stringToEncode = '{"componentDef":"forceSearch:search","attributes":{"term":"'+searchterm+'","scopeMap":{"resultsCmp":"forceSearch:resultsTopResults","label":"Top Results","type":"TOP_RESULTS","cacheable":"Y","id":"TOP_RESULTS","labelPlural":"Top Results"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"term":1234567890}}},"state":{}}'; | |
//convert to base64encode | |
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LightningRecordIdExampleController { | |
@AuraEnabled | |
public static Account getAccount(String accountId){ | |
return [select Id, Name, Type, Phone, Website, Industry from Account where Id=:accountId]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(component, event, helper) { | |
// create a one-time use instance of the getAccount action | |
// in the server-side controller | |
var action = component.get("c.getAccount"); | |
action.setParams({ | |
"accountId": component.get("v.recordId") | |
}); | |
// Create a callback that is executed after |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component controller="LightningRecordIdExampleController" implements="flexipage:availableForAllPageTypes,force:hasRecordId"> | |
<aura:attribute name="account" type="Account"/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<lightning:card iconName="standard:product" title="{!v.account.Name}"> | |
</lightning:card> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmpApi_exampleController { | |
@AuraEnabled | |
public static void publishEvent() | |
{ | |
System.debug('Published Event!'); | |
Demo_EmpApi_Event__e event = new Demo_EmpApi_Event__e(Message__c=message); | |
Database.SaveResult result = EventBus.publish(event); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(cmp, event, helper, isinit) { | |
var empApi = cmp.find("empApi"); | |
// Handle any errors and print them to the console. | |
var errorHandler = function (message) { | |
console.log("Received error ", message); | |
}.bind(this); | |
// Register the error listener |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component controller="EmpApi_exampleController" implements="force:appHostable"> | |
<lightning:empApi aura:id="empApi" /> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<lightning:card title="Emp API Example"> | |
<lightning:button variant="brand" label="Publish Event" onclick="{!c.doPublishEvent}" /> | |
</lightning:card> | |
</aura:component> |