57

My condolences if you're reading this, because it means that you're being tortured by an extremely useless and vague error message. Let's see if we can get through this without tearing out too much hair. :-) Deployment Error or DML Error? If you Google "duplicate value found: <unknown>...", the results you get will cover a wide variety of ...


48

Salesforce platform has a feature ROW LEVEL Security. This feature ensures that sharing and visibility set by salesforce administrators for the records have to be maintained. As a part of this feature, there are sharing calculations that the platform has to perform when the record ownership is changed or child records are created/modified. Assume that a ...


42

The error happens when you're trying to insert/update the record which can't be logically inserted/updated. So basically make sure that: you don't insert/update a record that does not exist, you don't update object field that is build-in/read-only, you perform the action using the user who has not the right access to modify the object More detailed ...


38

Apply the NavigationMixin function to your component’s base class: export default class MyLwcComponent extends NavigationMixin(LightningElement) { Hopefully this saves 3 mins of searching for those who (like me) only skimmed the documentation before diving in :)


37

What the main point of try/catch? To catch and handle an exception. The handling is the key. What it means to handle an exception is to take an exceptional situation - something bad and out of the ordinary happened - and allow the application to safely move back into an anticipated pathway of operation, preserving The integrity of the data involved. The ...


26

You may need to set escape parameter to false in your VF page. <apex:pageMessages escape="false"/>


19

Sadly I have to report the answer to your question is no. For me this is the final peace of Dynamic Apex to complete the ability to build truly 100% dynamic Apex libraries and solutions. I've searched for workarounds and can find none, the addError methods on SObject use a highly specialised way to reference the field which is to hard code the field ...


14

always in DML operations That's a common misconception. If you're using partial saves (e.g. Database.insert(records, false);), there's never a time where you need try-catch, as any exception is gracefully transformed into something your code can handle (except LimitException, which would kill the transaction uncontrollably anyways). You should catch ...


12

You have your DML statement inside of the for loop. So it is trying to insert the list each time through the loop. This will work fine for a single transaction, but the minute you do this with more than 1 transaction, it will fail. In the case of multiple transactions, the first time through the loop, it will work fine, as there is only 1 opp in it. ...


12

What I use is a component which handles those calls and turns errors into toasts: ToastErrorHandler.cmp: <aura:component > <aura:method name="handleResponse" action="{!c.handleResponse}"> <aura:attribute name="response" type="Object" /> <aura:attribute name="successHandler" type="Object" /> <aura:...


10

According to the license documentation: http://login.salesforce.com/help/doc/en/users_understanding_license_types.htm "Users with this license have read and create access on ideas and questions and answers, and read-only access to documents, knowledge, price books, and products" - plus you can access custom objects. I'm surprised that you can insert an ...


10

You are only allowed to use single quotes in your query. Replace all of your double quote characters (") with single quote characters (').


10

Setting just system.debug won't help you much since in orgs where your package is installed might have lot of other codes that might lead to logs truncation and your debug statements getting lost. The better solutions are: Use a custom object to log all these errors that you can query and report on . If you are worried about storage limits then prefer ...


10

Precision is the total number of digits allowed both left and right of the decimal, and scale is the number of digits to the right of the decimal. The number of digits just to the left of the decimal is precision-scale, or in other words, 2 significant digits. As configured, the field's maximum value is 99.99999999. You'd want to edit the field to allow 3 ...


9

First please take a look at this answer for a partial solution / approach, Can I prevent an insert to be rolled back even if my class (later) runs into an exception?. Basically as per the Apex Developers guide the final commit transaction management is baked into Apex, meaning it will always rollback if you let the platform handle your exceptions, if you ...


9

If you use the label attributed on your selectRadio, that value would be displayed instead of the j-id0..... <apex:page standardController="Account" extensions="EventController"> <apex:form > <apex:pageMessages></apex:pageMessages> <apex:pageBlock > <p> Please select </p> <apex:selectRadio value="{!...


8

This usually means: Something is being deployed via API (check Setup -> Monitor Deployments) Something is being deployed via changesets (Setup -> Deploy -> Inbound change sets) You're running some unit tests. Your request (from developer console, Eclipse or whatever) might have been canceled / timed out but the deployment still runs. One of these means ...


8

There are some alternative ways to display error messages, but like @Mark Pond answered you cannot clear the ApexPages.getMessages(). Also, you cannot iterate over it and replace the elements on it, or rather you can but it doesn't stick just like you observed with the clear() call. I suspect that the List that is returned by getMessages() is defensive ...


8

You can overwrite the standard salesforce error message css classes. In my example i have a simple error message with only short summary and a custom icon. So i took all error css classes and changed the icon. Then i have wrapped my message in a outputPanel and edited the message class (but only for this output panel): removed background and border. You can ...


8

As a follow up to this thread and to answer this question should anyone happen up this, here is what I discovered: The Auth.RegistrationHandler interface at the heart of this question has two main methods, as Andy noted, createUser() and updateUser(). The former returns a user and the latter is a void method. I tried Andy's suggestion and pattern of try/...


8

@Shebin answered your specific question, but there are a few issue with your trigger, the most important being that it is not bulkified. you always want to avoid SOQL inside loops. Something like below is a bit safer to use trigger AccountDuplicateTrigger on Account (before insert,before update) { //You may need to filter this a bit more if you have ...


8

There has been a change to the way that integer.valueof() handles NULL values. This line: decimal.valueOf(integer.valueof(mod.get('Average_Ratings__c'))) no longer works but this: decimal.valueOf(0) is a good work around if mod.get('Average_Ratings__c') = NULL


8

Yes, you can certainly send an email to the user; in fact, this is my preferred method to avoid spamming users. You can do this by way of the Database.Stateful. public class MyBatchable implements Database.Batchable<SObject>, Database.Stateful { Exception[] errors = new Exception[0]; public Iterable<SObject> start(...) { ... }...


8

we had a similar requirement and the way we fixed it was to put the entire form inside an aura:if and changed the Boolean condition. this essentially meant the dom got re-created again but we were able to reset 4 to 5 fields in one condition. <aura:component > <aura:attribute name="truthy" default="true" type="boolean"/> <lightning:...


7

Try catching errors as below : catch(Exception e) { String error = e.getMessage(); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,error)); } Instead of just doing ApexPages.addMessages(e); Using this in conjunction with Apexpages.hasMessages() if(some_condition){ ...


7

Have you considered adding try/catch logic around any code that might cause an exception and then using the addError() method to display a more friendly error message to the user?


7

Salesforce by default escapes any html in the addError String. To work around this, use the addError method with additional 'escape' parameter at the end: oppsByOppId.get(mrf.Opportunity__c).addError(' No Budget record was found for MRF record(s) with ' + errorMessage + '<br/>' + ' [WE_MRFv3]',false); The above should at least put [WE_MRFv3] on a new ...


7

The Fatal level is intended to materialize errors that occur at the platform level, while the Error level is intended for errors that are not strictly fatal, which accounts for pretty much every error that we developers have control over. For example, a Fatal error might be when SOSL fails to run because the search sub-system is down, while a normal Error ...


7

The problem is with how you are looking to reference the trigger.new context. The binding expression : must be used as follows. trigger AccountAddressTrigger on Account (after insert, after update) { List<Account> accs = [ SELECT ShippingPostalCode, BillingPostalCode FROM Account WHERE Id IN :Trigger.New ]; }


7

You don't have to throw AuraException, instead, you have to throw AuraHandledException @AuraEnabled public static string insertAccount(){ try{ // a required field is missing insert new Account(); } catch(Exception e){ System.debug(Logginglevel.ERROR, e.getMessage()); throw new ...


Only top voted, non community-wiki answers of a minimum length are eligible