Posts

Trigger 4 - Trigger to prevent duplication of an Account record based on Name whenever a record is inserted or updated.

 Trigger 4 scenario - Trigger to prevent duplication of an Account record based on Name whenever a record is inserted or updated. trigger AccountTrigger on Account (before insert , before update ) { if (Trigger.isBefore) { if (Trigger.isInsert) { AccountTriggerHandler.preventDuplicateNames(Trigger. new , null ); } else if (Trigger.isUpdate) { AccountTriggerHandler.preventDuplicateNames(Trigger. new , Trigger.oldMap); } } } public class AccountTriggerHandler {     public static void preventDuplicateNames(List<Account> newAccounts, Map<Id, Account> oldAccountMap) {         Set<String> newAccountNames = new Set<String>();         List<Account> recordsToValidate = new List<Account>();         // 1. Isolate the names being added or changed         for (Account acc : newAccounts) {   ...

Trigger 3 - Roll up Summary Trigger

 Trigger to count the number of Contacts associated with an Account and display the Contacts count on the Account's custom field. trigger ContactTrigger on Contact (after insert, after update, after delete, after undelete) {     if (Trigger.isAfter) {         if (Trigger.isInsert || Trigger.isUndelete) {             ContactTriggerHandler.countContacts(Trigger.new, null);         }          else if (Trigger.isUpdate) {             ContactTriggerHandler.countContacts(Trigger.new, Trigger.oldMap);         }          else if (Trigger.isDelete) {             ContactTriggerHandler.countContacts(null, Trigger.oldMap);         }     } } public class ContactTriggerHandler {          public static void countContacts(List<Contact...

Trigger 2 - Whenever a Contact's description is updated, then its Parent Account's description should also get updated by it.

 Whenever a Contact's description is updated, then its Parent Account's description should also get updated by it. trigger AccountTrigger on Account (after update) {     if (Trigger.isAfter && Trigger.isUpdate) {         AccountTriggerHandler.handleAfterUpdate(Trigger.new, Trigger.oldMap);     } } public with sharing class AccountTriggerHandler {          public static void handleAfterUpdate(List<Account> newAccounts, Map<Id, Account> oldAccountMap) {         Set<Id> accountIdsWithUpdatedPhone = new Set<Id>();                  // Loop 1: Find parent accounts where the target field actually changed         for (Account newAcc : newAccounts) {             Account oldAcc = oldAccountMap.get(newAcc.Id);                     ...

Trigger 1 - Whenever Account's Phone field is updated, all related Contacts' Phone field should also be updated with the parent Account's Phone.

 Whenever Account's Phone field is updated, all related Contacts' Phone field should also be updated with the parent Account's Phone. trigger AccountTrigger on Account (after update) {     if (Trigger.isAfter && Trigger.isUpdate) {         AccountTriggerHandler.handleAfterUpdate(Trigger.new, Trigger.oldMap);     } } public with sharing class AccountTriggerHandler {          public static void handleAfterUpdate(List<Account> newAccounts, Map<Id, Account> oldAccountMap) {         Set<Id> accountIdsWithUpdatedPhone = new Set<Id>();                  // Loop 1: Identify accounts where the Phone field actually changed         for (Account newAcc : newAccounts) {             Account oldAcc = oldAccountMap.get(newAcc.Id);                ...

Permission set permission to up date CreatedDate

Image
 Permission set permission to up date CreatedDate

Debugging Record Visibility in Salesforce

  Debugging Record Visibility in Salesforce Here's a comprehensive guide to debug why a record is not visible to a user: 1. Check Object-Level Security (OLS) Profile & Permission Sets Go to Setup → Profiles → find the user's profile → check if the object has at least "Read" access Check all Permission Sets assigned to the user for object access Use Setup → Permission Set Groups if applicable Setup → Users → [User] → Permission Set Assignments Setup → Profiles → [Profile] → Object Settings → [Object] 2. Check Field-Level Security (FLS) Even if the record is visible, key fields might be hidden: Setup → Profiles → [Profile] → Field-Level Security → [Object] Or use Setup → Object Manager → [Object] → Fields → [Field] → Set Field-Level Security 3. Check Record-Level Access (Sharing) This is the most common culprit. Use the "Why Can't I See This Record?" tool or manual checks: A. Use the Record Access Checker (Best Tool) Setup → Shar...

Percent of total

Image
  Percent of total 1. Create Product "Smart TV" as below image.        Product Name  :   Smart TV       Product Code    :   Smart TV       Active : True Under section " Salesforce CPQ Pricing"  fiield value  Pricing Method = List 2. On Related tab add Price book entry as below Create Another Product  On related records Create Price book entry as below screen Then we will go to quote line editor and add these two products lets observe hiw these are behaving. even if we add product it's cost reflecting as "0"  If you observe Once "Smart Tv" Product added to quote Its price is reflecting If you observe any other product adding to quote line the tv instalation product price is impacting but this is not our expectation. It should reflect only for tv product only.