Posts

Showing posts with the label account

Salesforce Fact #886 | Check if account description is blank using flow

Image
Long text area cannot be referenced in Salesforce formula fields. But they can be referenced in flow formula resources. Suppose, we need a flag to indicate if the description field on account is empty or not. We can create a before save record-triggered flow on Account and check if it is blank in a formula resource and store the value in a checkbox field. Attached are the screenshots.

Salesforce Fact #821 | Accounts and related notes

Suppose we need to find out the related notes for the account records. We can use the below query: SELECT Id, Name, (SELECT Id, ContentDocumentId FROM ContentDocumentLinks WHERE ContentDocument.FileType='SNOTE') FROM Account Note: Note records are stored with filetype as 'SNOTE'

Salesforce Fact #760 | Territory Assignment rule on account save

Image
There is a checkbox 'Evaluate this account against territory rules on save' on the Account layout to run the territory assignment rules. In order to make the checkbox visible, go to Account Page Layout -> Layout Properties -> Select show on edit page. It can also be marked as checked by default if the option 'Default' is selected. Whenever an account is assigned to a territory using the territory assignment rule, an AccountShare row is created with RowCause='Territory'. Reference:  https://help.salesforce.com/s/articleView?id=000385116&type=1 Attached are the screenshots.

Salesforce Fact #664 | Case accountId & contactId auto populate in community

When creating a case from a community user, the ContactId is auto-populated with the contact associated with the logged in community user. The AccountId field is also auto-populated with the related account record.

Salesforce Fact #645 | Account and oldest related contact

Suppose we need to find out account and the corresponding latest contact record. Now, we can use inner SOQL query for that. We can improve the fetch by adding a where clause so that the result is returned for the accounts which are present in contact object, skipping the accounts which does not have any related contact at all. SELECT Id, Name, (SELECT Id, Name FROM Contacts ORDER BY CreatedDate DESC LIMIT 1) FROM Account  WHERE Id IN (SELECT AccountId FROM Contact) Note: This query is only for demonstration. We should put filter the records for only the accounts which are intended for.

Salesforce Fact #620 | Access share object records in trigger

Image
While changing the record owner, the sharing records with RowCause='Manual' gets deleted. If we want to access the records for some processing, we need to get them in before update context. In this example, we have an account record with two manual share records. Now, in case of before update we get correct data from the AccountShare table, in after update the records have been deleted. Attached are the screenshots. Note: The code snippet is only for demonstration purpose and coding best practices have not been covered.

Salesforce Fact #613 | Screen flow: Relate multiple contacts for an account

Image
Many times we need to relate an account with multiple existing contacts. We can create a screen flow with a contact lookup element to achieve this. Attached are the screenshots.