Questions tagged [adderror]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
37 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 ...
4
votes
1answer
42 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()+'/'+...
1
vote
0answers
16 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 ...
0
votes
1answer
24 views

Execution of BeforeUpdate caused by: System.FinalException: SObject row does not allow errors ()

I have created a trigger on the Opportunity object for before insert and before update, through which I am sending the Trigger.newMap variable as an argument to my apex class where I am checking the ...
0
votes
0answers
117 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
1answer
35 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
1answer
30 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
0answers
96 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
1answer
21 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
1answer
34 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 ...
0
votes
0answers
382 views

We hit a snag before update trigger

I wanna choose pricebook for opportunity automatically. For this i created some picklist fields for both object, and a trigger that select pricebook based on this fields. The trigger work properly ...
1
vote
1answer
111 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
3answers
220 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
118 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
102 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
128 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
148 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
1k 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
112 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
358 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
147 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
508 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
742 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
221 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!=''){ ...
3
votes
1answer
145 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
878 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
248 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
886 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
1k 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
58 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
1k 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
281 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
2answers
867 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
1k 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
26 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
2answers
2k 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
985 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
28 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
517 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
262 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
340 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
520 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
323 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
13 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
25 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
227 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
49 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
457 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 ...