Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [adderror]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
3answers
40 views

Error Handling in REST Webservice

I have exposed this Apex class as a webservice. So far so good, as I get the response when this Webservice is called from ARC or POstman. @RestResource(urlMapping='/ProcessAccount/*') global with ...
1
vote
1answer
55 views

Apex debug logs change trigger execution, makes addError(String) either throw or not throw exception

I have a fresh case of strange Apex behavior that is throwing me for an absolute loop. I have a trigger on after insert and after update that needs to cycle through some records. It will update ...
0
votes
1answer
32 views

addError() in TriggerHandler

i'm receiving lead records via API REST from an external service. If the record doesn't accomplish with the condition, i'm adding an addError() to the lead record. The problem is that i can't control ...
0
votes
1answer
28 views

Alternatives to add error

I've been using addError() to prevent dml insertions of records that don't accomplish with the validation rule. The problem is that using that, if i insert a list of 100 records and one fails, the ...
1
vote
1answer
31 views

Trigger addError('blah') -> Lightning Components JS alert('contense of addError('blah')')

I am sure my Title does not help much, but not sure how to shorten this question concisely. I have a Lightning Component that has the ability to update a case record. I have an APEX Trigger that ...
6
votes
2answers
307 views

Does addError() work outside of triggers?

I moved a method that sets addError() from a trigger into a Helper class. As I started writing test code for it it seems like the addError() is not actually preventing DML operations for the records ...
0
votes
1answer
43 views

Error in trigger “Variable does not exist”

trigger preventDuplicateAcc on Account (Before insert , Before update) { for (Account acc : Trigger.new) { List<Account> a = [Select id,Name from Account where Name=:acc.Name]; ...
0
votes
2answers
103 views

Display child trigger error in friendly way on parent record page

Example When updating an Account record, it fires an Account before update trigger which changes a child Contact record, which fires a Contact before update trigger, which validates the change and ...
1
vote
1answer
56 views

Unit testing addError without doing DML

We're big fans of doing unit tests using as little DML as possible, mocking SObjects using various techniques Here's a simple example public class FoosService { public void doBar(Set<Id> ids)...
0
votes
1answer
119 views

Trouble with AddError method

Sales Invoices are a custom child object of Opportunity. I'm trying to write a class that throws an error if the total of all sales invoices for a given opp goes above the opp's amount. Currently it ...
1
vote
1answer
261 views

Exception in Database.save result in trigger context

1) In my opportunityLineitemtrigger, I have a method which updates the opportunity. system.debug('######'); database.saveresult [] rst = database.update(oppList,true); system.debug('######'+rst); ...
1
vote
0answers
153 views

addError is not showing anything on Lightning task page?

We have code that adds error messages to objects, and the point is to do so regardless of being in classic or lightning, so addError was used. All we are doing is this: if(validationMessage!=''){ ...
2
votes
1answer
117 views

How to enforce CRUD and FLS in bulk trigger?

How to enforce CRUD and FLS in following situation (bulk trigger). Better idea is simply throw an exception or addError(errMsg) ? trigger CaseCommentTrigger on CaseComment (after insert) { List<...
0
votes
1answer
506 views

Bulk Update Accounts - trigger to throw error

I have a requirement that only if the accounts list has one record, the inspectionsToUpdate is updated. If there is more than one record in the accounts list, for example, because someone is trying to ...
3
votes
1answer
115 views

Sobject Row does not allow Errors on Cross Object Error Trigger

System.FinalException: SObject row does not allow errors When I attempt to test my error code. Other documentation I've read states that this would only occur if the error is not set to the record ...
1
vote
1answer
491 views

Before Delete addError() message not user friendly

I have a before delete trigger on Topic Assignment that I'm using to block a User from deleting a Topic from a Question in a lightning community. The trigger works fine and blocks the DML, however the ...
1
vote
4answers
788 views

Parent case cannot closed if any child case is opened using trigger not working

Parent case has multiple child cases when i am trying to closed parent case it closed now but according to requirment if any child case has status open or anything except Closed then parent case ...
0
votes
2answers
49 views

addError is not working and allowed to store more than 3 child for corresponding parent

Requirement : not allowed to save more than 3 child for a parent here is trigger code trigger counterCh on Contact(before insert,before update){ if(Trigger.isInsert || Trigger.isUpdate){ ...
7
votes
1answer
781 views

How to rethrow DmlExceptions as AuraHandledExceptions right

Exception handling in Lightning is a pain. Instead of Lightning showing regular exceptions one has to catch them in code and rethrow them as AuraHandledExceptions as shown below: try { .... ...
6
votes
1answer
223 views

Preventing duplicates with addError

So basically was trying to prevent duplicates in my Lead Trigger by checking the lead's email and crossing it with the Contact object in order to verify that no contact with the same email exists. ...
3
votes
1answer
297 views

Determine if an SObject has an error

Is there a way to calculate if an SObject in a trigger context has had an error added to it (either with addError or through a validation rule)? I have some trigger processes I don't want to run if ...
0
votes
1answer
643 views

How can I add custom error message and remove the error message thrown by Site.login in visualforce page?

How can I add custom error message and remove the error message thrown by Site.login in visualforce page? Im having trouble removing the error message thrown by Site.login that says "Error: Your ...
2
votes
0answers
24 views

Is it possible not to display INSERT FAILED Error in page, when our custom validation error is triggered

We have a visualforce page (Manage Packaged) that saves a record. We added a custom validation using trigger (addError method) to prevent it to save when a certain criteria is met. But when this is ...
0
votes
2answers
959 views

addError for multiple validation messages on the same record before insert trigger

In before insert trigger I need to verify couple of validations for which I have written 2 methods - Method1(casesList) and Method2(casesList). Both methods operate on the same list of cases in before ...
0
votes
2answers
678 views

when to use validation rule & trigger's add error method

what is the difference between validation rule & triggers add error method? mens when I can use validation rule & when use adderror method?
2
votes
2answers
2k views

Difference between addError(errorMsg) and addError(exceptionError)

Wondering if anyone can explain the difference between errors and exception errors, or, more specifically, when one should use addError(errorMsg) instead of addError(exceptionError)? The ...
0
votes
1answer
26 views

Public Write Access allows for mass edits, how to throttle editable batch size for certain users for specific field?

I need to conditionally restrict the number of records that apex allows to be edited, based on user profile, number of records in the save transaction, and an oldmap newmap field compare. See attempt/...
0
votes
3answers
324 views

Do apex methods invoke at the same time in a trigger?

Just want a sanity check.. I have two methods on the same Trigger (both are isBefore execution). Does it matter which order I execute them in the trigger? Or do they both execute at the same time? ...
1
vote
2answers
209 views

Why am I getting duplicate ApexMessages when concatenating string in a try/catch

I have two different approaches for adding an error to my visualforce page. The first approach I am concatenating a string at the end of exception. The second approach I am simply returning the ...
2
votes
2answers
291 views

The code block containing 'addError' is being executed but no error thrown during record save

The code block containing 'addError' is being executed but no error thrown during record save.
2
votes
1answer
490 views

Catching the exception “SObject row does not allow errors”

I'm writing a batch class that I'm hoping can utilize some existing trigger code. However, the trigger code uses the addError method, which causes my batch to fail with the message System....
0
votes
1answer
302 views

I am getting error when trying to use addError() on Account Object

I tested this in my dev org for Account object: Class: public class Account { } Trigger: trigger AccountTestTest on Account (before insert) { for(Account c: trigger.new){ c.addError('...
0
votes
0answers
12 views

For all the records on a object how to enforce that there can only be one record where a checkbox field would be checked?

I've a checkbox field on an object. Now, for all the records on this object there can only be one record where this checkbox field would be checked. Need help here as to how do I implement this? Edit:...
1
vote
0answers
22 views

Enforce DML statement to be failed within a batch

I am trying to make a DML statement in a batch to be failed. The reason for this is that I have logic executed in my batch in case the DML failed for some records. I would like to test it and get the ...
0
votes
1answer
169 views

How to add error message to opportunity record page

I have added a custom button on the Opportunity page which invokes an apex code. The invoked apex code is redirecting to the same Opportunity page. ... PageReference pg = new PageReference('/...
1
vote
0answers
46 views

HTML escape not working in Salesforce1

I am adding an error message to a record using the Sobject.addError(errorMsg, escape) method, and I am trying to add a clickable link to my customer service departments phone number. ptCaseObj....
2
votes
3answers
307 views

Disable Email Sent to Administrators from addError()

I created an addError() method in a trigger with a custom error message like so: item.addError('Hey! You aren't authorized to do that!'); I have also received error emails like so: Dear Admin,...
0
votes
1answer
1k views

Error in $A.getCallback() [TypeError: Invalid value used as weak map key] Failing descriptor: {markup://c:Top5Clients}. Please try again

I have two components 1)Top5Clients and 2)MessagesandAlerts which retrieves recodrs from their respective custom objects I want to display the two components side by side so I have included in a ...
0
votes
1answer
4k views

Use AddError() inside an Apex Class

Is there any way that we can use addError() inside an apex class? I know it will work properly inside a trigger. But i would like to have a separate class for all validations instead writing them ...
1
vote
1answer
1k views

Before Insert: Using __r to pull related data in a Trigger.New for loop results in nulls even though lookup relationship has Id

Situation: I am trying to build a custom validation rule via apex that will stop users from saving a charge item to a quote if the charge item exceeds the available product quantity. The charge item ...
1
vote
1answer
880 views

Apex addError() works only for text/number SObject fields, when use inlineEditSupport in pageBlockTable

I have few custom validations, which i use in my controller. And i found that not for all fields it works correctly. I figured out that it shows only message, but doesnt show error near the inputField ...
0
votes
1answer
498 views

Before Trigger Create Record - Error on Original Records

I am using a staging object in Salesforce to receive data from a middleware platform via SOAP API and I wish to then write a before (or after if need be) trigger which does the following: Splits the ...
1
vote
1answer
8k views

Add Line Break In Error Message

The below code builds an error message displaying the values from multiple records (typically 12). Map<String,Budget__c> budgetByIdentifier = new Map<String,Budget__c>([SELECT ...
0
votes
1answer
382 views

how to show error message on vfpage when user enter wrong datatype for field selected

<apex:pageBlock title="Find Duplicates"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> &...
5
votes
1answer
531 views

Error message in an Apex Trigger

I want to display an error message using apex trigger and display a list with bullets beside it, like record name 1 record name 2 in the error message. Is this possible with a trigger? addError() ...
3
votes
1answer
175 views

How to stop converting Lead to Account in trigger without addError() method

I would like to know how to stop converting Lead to Account in before insert trigger without addError() method? To be more precise I try to achieve the following: 1. Stop the process of converting ...
1
vote
1answer
703 views

Use addError method and make a DML operation

The problem that I am having is that I am using addError method in before insert trigger which actually rollback every DML I make including @future method calls, sending email, queueing batch jobs, or ...
2
votes
2answers
2k views

how to get error/validation messages in a variable either at page side or class side for field validations

I want to customize the error msg which comes like: when i give wrong format of email id to email field so on below the fields error appear Error: Invalid Email Address. at the same time in debug log ...
1
vote
2answers
276 views

Trigger Check to see if error message

I have a trigger that on save I want to add an error to my page, however if the user clicks save again I want it to let them. Is there a way to check to see if there was an error message on the page? ...
0
votes
2answers
967 views

Close/dismiss button in apex addmessage

I'm looking a way to have a close button on the pagemessage after it displays the message or dismiss after few seconds something similar to JQuery. VFP: <apex:pageMessages id="showmsg"></...