Posts

Showing posts with the label error

Salesforce Fact #915 | Issue with criteria based sharing rule in before trigger

Image
Do you know criteria based sharing rules work asynchronously, hence they don't work as expected in before insert triggers. In this example, we have two object Account(Parent) and Agent(Child) and there is lookup relationship present. Now, we have created a criteria based sharing rule on account such that it is in effect when the account number is 1234. While creating an agent record we are creating an account record and setting the account owner explicitly to test out the sharing rule. We encounter an error while creating a new agent record and the account lookup is populated with some value. However, it works fine with owner based sharing rules. Reference:  https://salesforce.stackexchange.com/questions/375247/when-does-sharing-rule-execute Attached are the screenshots. Note: The trigger code and sharing rules are only for demonstration purpose.

Salesforce Fact #900 | Getting error record details when allornone flag is true

Image
We can use Database.SaveResult class to know which records failed during DML operation when the allornone flag is false. Similarly, we can get the details of error records  using DmlException  when allornone flag is true. Reference:  https://salesforce.stackexchange.com/questions/410070/return-database-saveresult-when-allornone-is-set-to-true Attached are the screenshots.

Salesforce Fact #888 | Handle error in common getRecords LWC

Image
Suppose you have an LWC which has a getRecord and is getting used across multiple object record pages. Now, if the fieldList is not consistent with the recordId then error is encountered. So, in order to handle this, we can check the sobjecttype and for the respective sobject we can return respective fields and if there is no logic built yet for any sobject, we can just pass the Id or empty array in the fields property to avoid the error. Attached is the screenshot.

Salesforce Fact #884 | LWC getRecord optionalFields in action

Image
The LWC getRecord optionalFields parameter is pretty helpful to deal with fields which have been used in the getRecord but the current user does not have access to. If we specify the same field in fields parameter, the call to getRecord fails with error, while if the same field is used in optionalFields it is ignored and the data is returned for the rest of the fields. In this example, the current user does not have access to the Account Description field. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-wire-adapters-record.html Attached are the screenshots.

Salesforce Fact #878 | (already output) error in debug log

Image
Have you encountered the error (already output) in the debug log? This error is encountered whenever the collection is not initialized or reinitialized properly in the code logic and it might lead to unexpected results. Reference:  https://salesforce.stackexchange.com/questions/290468/to-know-more-about-already-output-in-logs Attached is an example screenshot.

Salesforce Fact #842 | Error while using custom metadata methods

Have you encountered the below error while accessing custom metadata records using built-in methods: system.typeexception: unsupported sobject type and/or version This is because the metadata type methods were introduced in API version 51. So, please update the API version of the apex class to v51 or higher to resolve this. Reference:  https://salesforce.stackexchange.com/questions/339818/custom-metadata-types-not-supported-in-apex-classes

Salesforce Fact #801 | Org wide email address error

Have you come across this error while sending out email from apex code? 'INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address' This error is encountered when the specified org wide email address is not enabled for the current user's profile. To check this, Go to Setup -> Organization-Wide Addresses -> Check if the profile is present under allowed profiles.

Salesforce Fact #796 | Lead already converted

If we try to convert an already converted lead by mistake, we encounter the error 'CANNOT_UPDATE_CONVERTED_LEAD'. It shows the date as well on which the lead was converted. Reference:  https://help.salesforce.com/s/articleView?id=000384333&type=1

Salesforce Fact #779 | Error during emptyRecycleBin()

Image
While using the Database.emptyRecycleBin() method, if there are cascade delete relationship between records then only the top level record id needs to be specified. For example, if there are account and related contact records which are to be hard deleted, only the account record id needs to be specified. Otherwise, if both the account and contact record ids are specified, we get the error: 'Invalid record id; no recycle bin entry found'. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_database.htm#apex_System_Database_emptyRecycleBin Attached are the screenshots.

Salesforce Fact #776 | Error while deleting file association with library

Have you encountered this error:  Cannot complete this operation. You cannot remove a document from its owning library. So, whenever we associate a file to a library, a record gets created in each of ContentWorkspaceDoc and ContentDocumentLink objects. If we try to delete any of these records, it throws the error. So, the file or the ContentDocument record itself needs to be deleted to delete the associations. Reference:  https://salesforce.stackexchange.com/questions/317241/delete-a-contentdocumentlink-of-library-file

Salesforce Fact #744 | Named credential error

Have you encountered this error: 'The callout couldn't access the endpoint, You might not have the required permissions or the named credential <Named Credential name> does not exist'. One of the reason could be the user doesn't have access to the 'User External Credentials' object. To resolve this, provide Read access to the user on this object. Reference:  https://salesforce.stackexchange.com/questions/398401/named-credential-not-accessible-by-non-system-admin-profiles

Salesforce Fact #722 | validation rule message for inaccessible field

We have two options to display validation rule error message in UI: Field/Top of page. Now, if the field is not present in the layout or if the user does not have access to the field, the error position gets changed to 'Top of Page' automatically. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_validationrule.htm

Salesforce Fact #714 | Error while deactivating picklist value

Have you encountered this error while deactivating a picklist value 'The picklist value you attempted to delete is the last value for the following record types'. In order to avoid the error, we need to go to the particular record type and the picklist field, then move the value from the 'Selected Values' section to 'Available Values' section and ensure there is at least one other value is selected. Now, we are good to deactivate the picklist value. Reference:  https://help.salesforce.com/s/articleView?id=000386677&type=1

Salesforce Fact #686 | Email approval error

Image
What happens when the approver does not have access to the record, but tries to approve/reject the request from email response. An email is received stating that the user does not have access to update the referenced object. Attached is the screenshot.

Salesforce Fact #563 | @wire apex error

So what is the error you get if you call an apex method in @wire which is not annotated with (@AuraEnabled(cacheable=true). 'Apex methods that are to be cached must be marked as  @AuraEnabled(cacheable=true)'.