I have a trigger that when an opportunity stage name is closed won, it creates a new opportunity. My question is how do I go about linking opportunities together with an actual link back to the old opportunity.
At the moment opportunity name field has the same name as the closed won opp, but I would like to know how to code the link as well. I have tried getting opp id and name but that just gives me errors.
This is a code snippet where the fields are set.
// Create opportunity
Opportunity newOpp = new Opportunity(
Name = opp.get(opp.id),
RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Dealership').getRecordTypeId(),
AccountId = dealershipId,
CloseDate = Date.today(),
StageName = 'Group Contract Signed'
);