trigger to prevent delete related record based on lookup relation in salesforce -- w3web.net

Trigger on custom object to prevent delete the related list record based on lookup relation whenever trying to delete parent record, throw an error message using apex class handler trigger in Salesforce | How to prevent delete if parent object has child in Salesforce

1,833 views

Hey guys, today in this post we are going to learn about How to write a Trigger on custom object to prevent delete the related list record based on lookup relation whenever trying to delete parent record, display error message using apex class handler trigger in Salesforce

Real time scenarios:- Write a trigger to prevent delete the related list record. Whenever trying to delete parent record, trigger should be throw an error.

Files we used in this post example

scoreCardTrigger.apxt Apex Class Trigger It will be fired whenever trying to delete related list record.
scoreCardTriggerHandler.apxc Apex Class Controller Apex handler trigger to prevent delete the related list record whenever trying to delete parent record.
Custom Object:- scoreCard__c
Custom Fields:- scoreCardLookup__c (Lookup Relation)

Trigger to prevent delete the related list record based on lookup relation.

Final Output

trigger to prevent delete related record in salesforce -- w3web.net

Other related post that would you like to learn in Salesforce

  • Find the below steps for this post.

Create Apex Trigger

Step 1:- Apex Class Trigger : scoreCardTrigger.apxt

From Developer Console ➡ File ➡ New ➡ Apex Trigger

contactTriggerRollSummary.apxt [Apex Class Trigger]

Create Apex Class Trigger Handler Controller

Step 2:- Create Apex Class : scoreCardTriggerHandler.apxc

From Developer Console ➡ File ➡ New ➡ Apex Class

scoreCardTriggerHandler.apxc [Apex Class Controller]

trigger to prevent delete related record in salesforce -- w3web.net

Further post that would you like to learn in Salesforce

 

To Find Some Important Additional Information
If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free and Get Magic.. Get Started for Free

Check Out Youtube:- Earn Unlimited Everyday With This Trick:- Click Here

 

 

FAQ (Frequently Asked Questions)

How do you prevent duplicate records?

You can use the DISTINCT or DISTINCTROW identifier to eliminate duplicate records. DISTINCT and DISTINCTROW are synonyms and specify removal of duplicate rows from the result set.

How do I manage duplicate leads in Salesforce?

To manage duplicates that aren't surfaced by a duplicate rule, create a duplicate record set.

How do I stop inserting duplicate records in MySQL?

Use the INSERT IGNORE command rather than the INSERT command. If a record doesn't duplicate an existing record, then MySQL inserts it as usual. If the record is a duplicate, then the IGNORE keyword tells MySQL to discard it silently without generating an error.

Related Topics | You May Also Like

  • Your reaction of the article ▾
 

Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

4 thoughts on “Trigger on custom object to prevent delete the related list record based on lookup relation whenever trying to delete parent record, throw an error message using apex class handler trigger in Salesforce | How to prevent delete if parent object has child in Salesforce”

Leave a Comment