Have 2 managed packages.
- One package contains Recurring object.
- Another package contains Receipt object.
- Opportunity has lookup fields to Recurring object and to Receipt.
- Created text field 'Donations List' on Recurring to see list of all receipts for this recurring.
Created trigger on Opportunity after update trigger checks if Opportunity lookup to Recurring is not empty execute SOQL to get all receipt names from receipts.
SELECT Id, Name, Receipt__c, Receipt__r.Name FROM Opportunity WHERE Recurring__c=:recurringID
The problem is - when Receipt creates it populates receipt__c field on opportunity and saves the opportunity. On Saving Opportunity trigger fires to get receipt number populate into recurring object, but SOQL does not return correct receipt number. SOQL returns Receipt ID for Receipt__c field and returns [Name Set by Trigger] for Receipt__r.Name.
Is there a way to get correct receipt number in this situation?
It seems like when receipt creates it has a trigger on insert/update that updates Opportunity lookup field Receipt__c. At the same time on Opportunity (using another trigger) I'am getting Receipt number of receipt that invoked opportunity changing.