function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
WikWik 

Trigger Suggestion

Hi,

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 !!
dev_sfdc1dev_sfdc1
Hi wik,

please refer this link will help you

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008oyrIAA

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008n49IAA

Thank You
WikWik
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