How to remove duplicates from list in Salesforce?
Create a map instead of list and finally insert or update the map values. Check the following code to remove duplicates from list in Salesforce. Sample Code: Map < Id, ....
Create a map instead of list and finally insert or update the map values. Check the following code to remove duplicates from list in Salesforce. Sample Code: Map < Id, ....
clone(Boolean, Boolean, Boolean, Boolean): Creates a copy of the sObject record. Parameters opt_preserve_id Type: Boolean Determines whether the ID of the original object is preserved or cleared in the duplicate. ....
Use null value to make the Date field null. Sample Code: Account objAccount = [ SELECT Id FROM Account WHERE Name = 'InfallibleTechie' LIMIT 1 ]; Asset objAsset = new ....
Abstract Class: public abstract class SampleAbstract { public Task newTask; public void createT(Id caseId, Id accountId) { newTask = new Task(); ....
Using System.Schedule(), we can delay our execution to avoid concurrent batch execution in Salesforce. Sample Code: if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR Status = 'Preparing')] ....
Visualforce page: <apex:page standardController="Member__c" extensions="MemberExt" recordSetVar="Member"> <apex:pageBlock > <apex:pageBlockTable value="{!memList}" var="M"> <apex:column value="{!M.Name}"/> ....
removeEnd() can be used to remove the last character from a String in Salesforce Apex. Sample Code: String str = 'Approved/Rejected/'; str = str.removeEnd('/'); system.debug('Value is ' + str); Output: ....
assignmentRuleHeader.useDefaultRule should be set to true in Database.DMLOptions to fire Assignment Rule when a Lead is created using Apex. Sample Code: Lead objLead = new Lead( FirstName = 'Test1', LastName ....
Sample Code: DescribeSObjectResult sobjectRes = Employee__c.sObjectType.getDescribe(); system.debug('Object Label is ' + sobjectRes.getLabel()); system.debug('Key prefix is ' + sobjectRes.getKeyPrefix()); system.debug('Plural Label is ' + sobjectRes.getLabelPlural()); system.debug('Object Name is ' + sobjectRes.getName()); ....
Sample Query: SELECT PricebookEntry.Product2.Name FROM OpportunityLineItem (Or) SELECT PricebookEntry.Name FROM OpportunityLineItem LIMIT 10 Sample Code: for ( OpportunityLineItem OLI : [ SELECT PricebookEntry.Product2.Name, PricebookEntry.Name FROM OpportunityLineItem LIMIT 10 ] ) ....