2022 Developer Survey is open! Take survey.

New answers tagged

2 votes

can we close a case in before trigger? Case status still show Open

You're literally creating new cases when your conditions are met. Instead, just update the records in Trigger.new: for(case c:trigger.new){ system.debug('recordtypeid: '+c.RecordTypeId); if(c....
user avatar
  • 430k
2 votes
Accepted

Trigger to prevent deletion of account which has atleast one contact linked to it not working

If you want to add an error when you are trying to delete account than you need to Retrieve all related contacts Loop through each contact and add AccountId to Set Loop through accounts and add an ...
user avatar
0 votes

Trigger to prevent deletion of account which has atleast one contact linked to it not working

How are you getting the Contacts?? Basically, your code is getting nothing when you say acc.Contacts. Try debugging it in the System debug and check what is the value in your acc.Contacts. trigger ...
user avatar
  • 116
0 votes

execute logic beforedelete event trigger

If you let beforeDelete pass through without throwing error, Salesforce will delete the record immediately and put into recycle bin. Since triggers cannot make callouts, you will have to notify ...
user avatar
  • 1,493
1 vote
Accepted

Display AddError message on Contact Page

You cannot call addError() on every SObject instance, it must be a record from Trigger.new/Trigger.newMap (for insert and update trigger) or Trigger.old/Trigger.oldMap (for delete trigger). Trigger ...
user avatar
  • 3,325
1 vote
Accepted

Null checking before Update DML

Yes you will have the value. You do not need to have update statement for trigger.new in before triggers. The value will automatically update in the records. You can validate the values using System....
user avatar
  • 741
2 votes

How To Format Helper Class In Trigger Handler Framework?

The doTask1 method defined at AccountTriggerHelper expects a List but you're not passing any as argument when you call it from the beforeInsert method. Instead you should have: public void ...
user avatar

Top 50 recent answers are included