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
sfunstonsfunston 

How to identify the record that fired a trigger

    Hi

I am trying to figure out if there is something like the virtural inserted table from mssql in SalesForce.

What I want to do is create a trigger on a Custom  Object (CustObject) that has a master detail relationship with Opportunity.  So when a record is inserted into CustObject I want to find all the other records in CustObject that have the same Opportunity__c and update only those records.



Any ideas would be appreciated.
santoshsantosh

This is what you could do... in your after insert trigger

List<CustObject__c> objects = [SELECT ID FROM CustObject__c WHERE Opportunity = :Trigger.new.Opportunity];
for(integer i = 0; i < objects.size(); i++)
{
 object[i].FieldName = NewValue;
.
.
.
.
}
update objects;
sfunstonsfunston
Hi santosh.  Thanks for the reply.

Am I correct in thatTrigger.new is the new record that fired the triggered?
santoshsantosh
Yes, that's right