How To Delete Opportunity In Salesforce
i,668 views
Hey guys, today in this post we are going to learn most How to write a apex trigger whenever opportunity is deleted the corresponding account and contact should be deleted uses of Apex trigger in Salesforce.
Existent time scenarios:- Write a trigger on Opportunity when Opportunity is deleted the corresponding Account and Contact should be automated deleted.
Apex Triggers
Apex can be invoked past using triggers. Noon triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions.
A trigger is Apex lawmaking that executes earlier or after the following types of operations:-
- insert
- update
- delete
- merge
- upsert
- undelete
To know more details about Noon Triggers, Click Hither →
- Don't forget to cheque out:- Create Duplicate Rule & Matching Rule to Prevent Insert/Update Duplicate Records on Contact sObject based on Contact E-mail and Contact Phone in Salesforce. Click Hither For More Information
Concluding Output →
Other related post that would y'all like to learn in Salesforce
- Notice the beneath steps ▾
Create Apex Trigger
Step 1:- Create Apex Trigger : OpportunityDeleteTrigger.apxt
From Developer Console >> File >> New >> Apex Trigger
OpportunityDeleteTrigger.apxt [Noon Trigger]
i 2 iii iv v half-dozen 7 viii 9 ten 11 12 13 14 15 16 17 eighteen 19 xx 21 22 23 24 25 26 27 28 29 | trigger OpportunityDeleteTrigger on Opportunity ( earlier delete , after delete ) { if ( trigger . isBefore ) { system . debug ( 'trigger earlier trigger' ) ; } else if ( trigger . isAfter ) { organisation . debug ( 'trigger later trigger' ) ; if ( trigger . isDelete ) { Map < Id , Opportunity > oppItemMap = new Map < Id , Opportunity > ( ) ; for ( Opportunity opp : Trigger . onetime ) { oppItemMap . put ( opp . AccountId , opp ) ; } Listing < Account > oppRelListDelete = new List < Account > ( ) ; Listing < Business relationship > accObjlist = [ select Id , Name , Industry , Website , Type , Phone , Clarification From Business relationship where Id in : oppItemMap . keyset ( ) ] ; for ( Account acc : accObjlist ) { oppRelListDelete . add ( acc ) ; } if ( ! oppRelListDelete . isEmpty ( ) && oppRelListDelete . size ( ) > 0 ) { delete oppRelListDelete ; } } } } |
Further post that would you like to learn in Salesforce
FAQ (Frequently Asked Questions)
Does Later on trigger piece of work on delete?
rigger After Delete Salesforce executes the custom logic after the data is deleted from the Salesforce Database. If yous are looking to delete related records, you can brand apply of Trigger After Delete Salesforce.
What is trigger isInsert?
isInsert. Returns truthful if this trigger was fired due to an insert performance, from the Salesforce user interface, Apex, or the API. isUpdate. Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.
What is the difference between trigger new and trigger old?
new : Returns a list of the new versions of the sObject records. Note that this sObject list is only bachelor in insert and update triggers, and the records can merely be modified in earlier triggers. Trigger. old : Returns a listing of the quondam versions of the sObject records.
- Your reaction of the article ▾
Source: https://www.w3web.net/trigger-to-deleted-relted-list-of-opportunity/
0 Response to "How To Delete Opportunity In Salesforce"
Post a Comment