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
Amy ThroppAmy Thropp 

Is there a way to know if request to add a related object record was initiated from the parent's related list?

I have a custom object that acts as a parent for a grouping of opportunities of a specific record type. If a user clicks "Add" on the Opportunity related list on this custom object, a trigger on the opportunity object execs to pre-populate certain fields on the opportunity record (some custom, some standard).  Here's the trigger:

trigger GOPlanOppSync on Opportunity (before insert, before update) {

   //Loop through all records in the Trigger.new collection
   for(opportunity o: Trigger.new){
       if (o.recordtype.name =='HVAC GO Plan') {
           Go_Opp__c GOPlan = [SELECT
                                DC__c,
                               Id,
                               JDE_Agency__c,
                               JDE_Parent__c,
                               JDE_Region__c,
                               JDE_Rep__c,
                               NationalCust__c,
                               SF_Agency__c,
                               SF_Parent__c,
                               SF_Region__c,
                               SF_rep__c,
                               State__c,
                               text_ID__c
                               FROM Go_Opp__c where id=:o.Go_Plan_Opportunity__c];
           //update opp fields from go opp header
           o.jde_agency__c = GOPlan.JDE_Agency__c;
           o.accountID = GOPlan.SF_Parent__c;
           o.sf_agency__c = GOPlan.sf_agency__c;
           o.sf_region__c = GOPlan.sf_region__c;
           o.sf_rep__c = GOPlan.sf_rep__c;
           o.Parent_text_ID__c = GOPlan.text_ID__c;
           o.text_id__c = GOPlan.jde_region__c.trim()+GOPlan.jde_agency__c.trim()+GOPlan.jde_parent__c.trim()+o.jde_category__c.trim()+GOPlan.state__c.trim();
           if (GOPlan.nationalcust__c) {
               o.text_id__c=o.text_id__c+'1';
           } else {
               o.text_id__c = o.text_id__c+'0';
           }
           if (GOPlan.dc__c) {
               o.text_id__c = o.text_Id__c + '1';
           } else {
               o.text_id__c = o.text_id__c + '0';
           }
       }
   }
}

If the user just sets up one of these opportunities from the Opportunity tab, I don't want the trigger to execute, but if they click on "Add" from the "Parent" object, then I want the trigger to execute.

What can I look for to determine if the "Add" was requested standalone (from the Opportunity page) or from the custom object's related list, so I can surpress the trigger except when coming from the related list?