Posts

CPU Time Out Salesforce.com introduced a new governor limit called CPU Timeout in winter 14, what exactly is CPU Time out and how its get calculated and whats get counted for CPU Timeout. As per Salesforce.com documentation CPU Timeout is calculated for all executions on the Salesforce application servers occurring in one apex transaction - for executing apex code and all the process called from code such as workflows, validation rules, package code. CPU Timeout is private for transaction and is isolated from other transactions. CPU Timeout for Synchronous apex:   10,000 milliseconds CPU Timeout for Asynchronous apex: 60,000 milliseconds  CPU Timeout Counted for: 1. Workflows 2. Validation Rule 3. Library functions exposed in apex code CPU Timeout do not count for: 1. SOSL 2. SOQL 3. DML 4. Http callouts CPU Timeout can be explained as Time taken by the apex transaction in a context including Apex code, Validation rules, Workflows ...
Image
Select Option Sorting List is an ordered collection of elements which can be of any data type - primitive types, collections, sObjects, that are distinguished by their indices. First element indices in List is always 0. we can sort the list using sort() method. For primitive data type sorting is always done in ascending order. example : List<String> names = new List<String>{ 'Pawan','Vishal','Vivek','Rishabh','Dinda', 'pawan'}; system.debug(' List before Sorting : ' + names); names.sort(); system.debug(' List after Sorting : ' + names); sorted list will be (Dinda, Pawan, Rishabh, Vishal, Vivek, pawan)       SelectOption is also sorts in ascending order using value and label fields  in sequence 1. The value of fields is used for sorting. 2. If value of fields have the same value or both are empty then label is used. NOTE : empty fields precede non-empty fields example: Lis...
Image
Load Test Data from Static Resource we write test class to test out functionality and in test class we create test data, but in Salesforce using Test.loadData method, you can populate data in our test method without writing any code. To load test data from Static Resource we have to create a .csv file and upload it to Static Resource copy and paste the below data and save the file in .csv extension. Name,Website,Phone,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry sForceTest1,http://www.sforcetest1.com,(415) 901-7000,The Landmark @ One Market,San Francisco,CA,94105,US sForceTest2,http://www.sforcetest2.com,(415) 901-7000,The Landmark @ One Market Suite 300,San Francisco,CA,94105,US sForceTest3,http://www.sforcetest3.com,(415) 901-7000,1 Market St,San Francisco,CA,94105,US go to Static Resource [ Setup -> Develop -> Static Resource ] create new Static Resource record, give Static Resource Name as "Test Records" and sav...
Image
Truncating Custom Objects Truncating custom Object allows you to remove all of the object's records, while keeping the object and its metadata. When you truncate a custom Object Salesforce places a truncated object in the Deleted Object list for 15 days.  It appears in deleted object list as objectname_trunc. NOTE : During this time, the truncated object and its record continue to count against your org limits. NOTE : Truncated Objects can not be restored to their original state. Truncating object is a fast way to permanently remove all of the records from an object, while keeping object and it metadata intact for future use. Lets play with truncation I have created a custom object "TestObject" and inserted few records. On object defination page I can not see "Truncate " button  to enable Truncate go to Setup -> Customize -> User Interface and select " Enable Custom Object Truncate " on saving it a new but...
Image
New Button in Look-up Window When you create a new Look-Up or Master-Detail field on any custom object or on any standard object and then during look-up you see a New button clicking on it will allow you to create a new record on run from look-up window. Before discussing more about it few important points to note : 1. This button is available only for Account and Contact. New Button for Account Look-up New Button for Contact Look-up No New Button for Opportunity, same for other custom and standard objects New Button for Master-Detail relationship with Account, same for Contact 2. Record created by clicking New button on look-up window will bypass validation rules. If you want to remove this "New" button from lookup window then you can do it from Setup -> Customize -> User Interface and deselect "Show Quick Create " and save the settings. after deselecting check the lookup window to confirm if New...
Image
Make Rich Text Field Mandatory Using Validation Rule If you want to make field of data type Rich Text mandatory, what would you do? One way to achieve this is by making field mandatory from page layout, that will work fine if you are creating records from salesforce UI but that won't work when you will upload data using Data-loader. What will be the next approach, writing validation rule ?  In validation rule you going to use ISNULL or ISBLANK ? Lets try with ISNULL and ISBLANK one by one 1. ISNULL : Determine if expression is null (blank) and return TRUE if it is. If it contains value, this function returns FALSE. create a validation rule and check ISNULL() for that rich text field like below snapshot. in validation rule I have checked ISNULL(Rich_Text__c) and saved it.  Now try to save the record without entering any value in Rich_Text__c field, validation rule won't work. Why ISNULL didn't work? According to Salesforce Text Fields are n...
Difference between SOQL and SOSL SOQL stands for Salesforce Object Query Language SOSL stands for Salesforce Object Search Language SOQL can be used in apex triggers, apex classes SOSL can not be used in apex triggers. SOQL returns Integer or list of sObject SOSL returns List of List of sObject SOQL can be used for DML operations SOSL can not be used for DML operations Total no. of SOQL queries issued : 100 Total no. of SOSL queries issued : 20 Total no. of records retrieved by SOQL query : 50,000 Total no. of records retrieved by SOSL query : 2,000 Use SOQL when 1. you know in which objects or fields the data resides. 2. you want to retrieve data from single object or multiple objects that are related to one another. 3. you want to count number of records meeting the criteria in query. 4. you want to sort the result. you want to retrieve data from number, date or checkbox fields. Use SOSL when 1. you don't know in which object or ...