+ Start a Discussion

Trigger Suggestion


There are 2 objects named A and B. These two object are connected through a Junction Object C.

A is the master of the Master Detail relation ship between A and C.

B and C are connected using a lookup relationship.
If i need to delete a record of object B based on certain condition of object A.

Then on which object do i need to write the trigger.

If there are examples for this sort of an application. Please suggest.

Any insight is appreciated.

Thank you.

RamuRamu (Salesforce Developers) 
Basically, you would need to write a trigger where there is some kind of DML operation involved. In your case as the criteria on object A is the key for the trigger to fire, you would be writing the trigger on object A. Hope this helps !!
Hi wik,

please refer this link will help you



Thank You
Thanx for the reply:

i wrote something as below:
trigger cascadeJunctionDelete on Opportunity_Equipment__c (after update) {

    List<Opportunity> oppList = new List<Opportunity>();

    List<Equipment__c> eqList = new List<Equipment__c>();

    for(Opportunity_Equipment__c ed : Trigger.old) {

if((Opportunity.StageName == 'Closed Lost' ||  Opportunity.StageName == 'Closed-Abandoned') && ( Equipment__c.Status__c == 'Pending Sales') ) {
        oppList.add(new Opportunity(id=ed.Opportunity__c));

        eqList.add(new Equipment__c(id=ed.Equipment__c)); }  


    if(eqList.size() > 0) {

        delete eqList;



But am geeting an error while saving this : 
Error: Compile Error: Comparison arguments must be compatible types: Schema.SObjectField, String at line 10 column 5
i.e. at the highlighted line