Posts

Showing posts from April, 2023

Get the record Count of all countable Sobjects in Salesforce

Image
  Salesforce: Get the record count of all objects Use case: A client wants to access the data volume for data migration and needs to get record counts from all countable objects in Salesforce Solution:  1) log in to Workbench 2) Go to Utilities > Rest Explorer 3) Do a GET call on this URI: /services/data/v56.0/limits/recordCount ( change 56.0 with the latest API version) 4) Check the result. Copy the JSON and convert it to CSV Note: 1) The Rest call result does not include uncountable objects and record count for deleted records in the recycle bin 2) Ensure your user has "View Setup and Configuration” permission

Show Hyperlink against the Record in Datatable in LWC

Image
  Requirements : Show the case records in the data table. when click on case number it will redirect to the detail page Apex Class: showCaseRecordsinDatatable public with sharing class showCaseRecordsinDatatable {        @AuraEnabled     public static list<case> fetchCases(){         try {             return [Select Id, subject,CaseNumber, Description, AccountID, Account.Name,ContactID, contact.Name,Status, priority from case];                    } catch (Exception e) {             throw new AuraHandledException(e.getMessage());         }     } } --------Create LWC------- <template>     <lightning-card  variant="Narrow"  title="Case List" icon-name="standard:case">         <div class="slds-m-around_small">             <lightning-datatable                 key-field="id"                 data={result}                 show-row-number-column                 hide-checkbox-column                 columns={columnsList}

Get Record based on Specific Date in SOQL using IN Operator

 We can use IN operator to put a filter on multiple dates while using the Day_Only function. Get specific date of records using IN operator with Day_Only Function  List<Account> lstofacc = [SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (2022-01-24, 2022-01-25)]; System.debug(accList); bind variables as well: Date d1 = Date.parse('01/24/2022'); Date d2 = Date.parse('01/25/2022'); List<Account> accList = [SELECT Id, Name, CreatedDate FROM Account WHERE Day_Only(CreatedDate) IN (:d1, :d2)]; System.debug(accList);