Example for System.assertEquals()
Sample Code: Trigger: trigger AccountTrigger on Account ( before insert ) { for ( Account acct : trigger.new ) { if ( acct.Name == 'Test Account' ) acct.Description = 'Test'; ....
Sample Code: Trigger: trigger AccountTrigger on Account ( before insert ) { for ( Account acct : trigger.new ) { if ( acct.Name == 'Test Account' ) acct.Description = 'Test'; ....
To write/develop a unit-test/test class for Salesforce Apex Triggers, then in the Test Class, we have to do the DML operations based on the events used in the Apex Trigger. ....
window.onload or action attribute in apex:page can be used as OnLoad function in Salesforce Visualforce page. Method 1(Calling Javascript): <script type = "text/javascript"> window.onload=function() { alert("Hi"); }; </script> Method 2(Calling ....
getChildRelationships() can be used to retrieve all the related or child objects of an object in Salesforce Apex. Sample code: Schema.DescribeSObjectResult objResult = Account.SObjectType.getDescribe(); List < Schema.ChildRelationship > objRelationships = ....
In order to use apex code to submit the record for Approval process, we have to first create Approval process in Create --> Workflow & Approvals. Sample code: void ....
Sample Code: Visualforce Page: <apex:page controller="SampleVisualforcePageController" id="pg"> <apex:form id="frm"> <apex:messages/> <apex:pageblock id="AccountsList" title="Accounts List" > <apex:pageBlocktable value="{!listAccounts}" var="acc" > <apex:column title="Select" > <apex:inputCheckbox value="{!acc.selectedBool}"> </apex:inputCheckbox> </apex:column> <apex:column value="{!acc.objAccount.Name}"/> </apex:pageBlocktable> <apex:pageblockButtons ....
PageReference can be used to navigate from the current page to a different page using Salesforce Apex. The below code is used to open new page 'AddAllBlog' from current page. ....
The below simple code is used to convert String to Date data type using Apex Sample Code: String todate = '12/27/2013'; Date dt = Date.parse( todate ); System.debug(' Parsed Date is ' + dt ); Output:
In this Blog Post, we are going to use Salesforce Apex to send email to a Public Group. Please check the following code for your reference. Sample Class: public class ....
Sample code: Apex: public class SampleController { public boolean displayPopup {get; set;} public void closePopup() { displayPopup = false; } public void showPopup() { displayPopup = true; } } Visualforce ....