Questions tagged [adderror]
The adderror tag has no usage guidance.
87
questions
0
votes
2
answers
64
views
Validation Rule error message always showing on top, not under the field
I have a validation rule and it should display the error message
under a checkbox field 'Consent received to add as a Contact ?' but it is always displaying the error on the header of the page.
I have ...
0
votes
1
answer
61
views
Validation Rule based on Trigger
I have validation rule need to be implemented by validation rule.
Issue object is child object of Case in Master Detail Relationship. If Primary Issue(Checkbox) is checked then Status in Case record ...
0
votes
1
answer
181
views
Possible to remove or ignore errors from trigger-context SObject after .addError() in Apex?
With Apex, after calling .addError() on a trigger record is there any way to subsequently remove that error such that the DML operation will complete successfully?
I don't see any Database methods (...
0
votes
1
answer
272
views
send email even with addError (platform event)
I need help to understanding why I can't send email even using platform event (publish immediately).
The business logic is to prevent duplicated lead basead on a field, show an error message in the UI ...
0
votes
1
answer
1k
views
How to display hyperlink in error message from trigger?
i want to give link to the record in an error message which i am sending from trigger.
Message:
ERROR: An open opportunity <a href='https://bonial3-dev-ed.my.salesforce.com/0065i000006VOl0AAG'>...
0
votes
1
answer
784
views
Apex trigger addError() always shows error-msg
Good day, everyone.
I have started learning Apex. And need help with triggers. The problem is:
I have custom object Gift Card, which is not related to any other objects. On Opportunity I have custom ...
0
votes
1
answer
3k
views
Create a custom error message with apex
I am trying to create an error message with apex when saving a quote.
I already have the logic done but I would like to know if I can create this type of error messages as shown in the image.
I don't ...
0
votes
0
answers
20
views
adding an existing user to my sales app
scenerio:
.......both user A and B are on salesforce......
user A runs a little Ad agency,
user B requires the help of User A, as a mentor.
My Question:
why can't it be possible for user B to invite ...
0
votes
1
answer
472
views
Handling errors with future callouts from Trigger
My design is that whenever an account is created, It calls an 'after insert' trigger that makes a future callout to an external system and sends the account details.
If there's an error in the future ...
0
votes
2
answers
1k
views
Query child records when relationship is with same object
I have a lookup field on case which points to case object. (Field: Parent__c). I want to query child case records from a parent case using an aggregate query. Below is the query I have used-
[SELECT ...
1
vote
1
answer
879
views
multiple addError() behaviour in apex
We have a trigger on the Account and Contact objects. The job of these triggers is to prevent the deletion of Account and Contact objects depending on the criteria.
Account should be deleted if no ...
-1
votes
1
answer
44
views
Display a proper error to user [closed]
may I know how to make the system show error to users in a proper way? Because I try to use adderror(), but still not working. it keeps showing the below error if the user does not fills in these ...
1
vote
2
answers
13k
views
AddError on Before Update
I am trying to display an error message if a field on Quote is updated to a certain value. I am doing it on before update but I am encountering an error
Here is a sample code block I am trying on my ...
-1
votes
1
answer
63
views
Can anyone explain logic inside trigger exception
trigger accountDeletion on Account (before delete) {
// Prevent the deletion of accounts if they have related opportunities.
for (Account a : [SELECT Id FROM Account
WHERE ...
0
votes
2
answers
101
views
How To Prevent creating Accounts In a specific month
I want to avoid Creation or Deletion of Accounts in a specific month(for eg December).
How can I achieve this. Because the createdDate is null in before Insert and addError does not run in after ...
5
votes
1
answer
949
views
How to display a error message with hyperlink on standard detail page through trigger
I'm trying to add the record link inside the "addError" on the trigger
for(Account account : (List<Account>) triggerParams.triggerNew) {
String url = URL.getOrgDomainUrl()+'/'+...
3
votes
0
answers
610
views
How to check for/retrieve record-specific error message, e.g. by errors added through sObject.addError or validation rule?
I'm wondering about the documentation for the sObject class (API 50).
It clearly states this for hasErrors():
Returns true if an SObject instance has associated errors. The error
message can be ...
1
vote
0
answers
3k
views
Apex Trigger to stop record from being saved in Salesforce
I have a requirement to stop the record from being saved when a checkbox is set to true in that record. This record is saved from Lightning component and on click of Save button from the component, ...
0
votes
1
answer
219
views
addError message is firing in one sandbox but not firing in other sandbox
I have a requirement that users should not be able to remove document from the closed cases. I have achieved this by writing a trigger on before delete on contentdocumentlink.
My old code was like as ...
0
votes
1
answer
311
views
AddError Not working on before update Trigger
I have a newbie issue.... hahaah
This is my code where I Need to avoid an update and show an error messaje if a lookup field has the status "Cerrado" but whith this code, the objects are ...
0
votes
0
answers
219
views
addError() method behavior on FeedItem trigger
I've written a basic trigger on FeedItem, which restricts users not to delete their chatter posts (simplified to clarify my question).
trigger beforeDeleteFeed on FeedItem (before delete) {
...
0
votes
1
answer
254
views
Test Class Opportunity Line Item, add error
I wrote a trigger to count the number of values in a multi-select picklist (custom_coins__c), if more than 10, error (too many coins selected). I'm new at writing code and can't figure out the test ...
0
votes
1
answer
690
views
Raising friendly user error from trigger context
I have after update trigger on contact.
I am trying to write a friendly error to screen whenever x is happening.(in apex code)
I followed this explanation:
Difference between the multiple messaging ...
1
vote
1
answer
357
views
Lead Trigger and lead.addError()
I have this problem with triggers:
We have integration with our backoffice to receive leads. Unfortunately, we can't change this integration. It sends the leads when when it shouldn't.
On insert if ...
0
votes
4
answers
2k
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
1
answer
368
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
1
answer
725
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
1
answer
602
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
1
answer
576
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
2
answers
5k
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
1
answer
808
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];
...
1
vote
2
answers
1k
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
2
answers
547
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
1
answer
2k
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
1
answer
2k
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
0
answers
310
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!=''){
...
4
votes
1
answer
201
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
1
answer
1k
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
1
answer
375
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
1
answer
2k
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
4
answers
3k
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
2
answers
204
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
1
answer
3k
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
1
answer
369
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.
...
5
votes
2
answers
2k
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
1
answer
2k
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
0
answers
39
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 ...
2
votes
3
answers
4k
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
2
answers
2k
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
2
answers
3k
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 ...