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

Using trigger on A Junction Object to automatically create records coming from two custom objects (as master detailed)

Hello... I need help on how I can accomplish the solution.
  • Custom Object 1 = Deposit__c
  • Custom Object 2 = Fee__c
  • Both Deposit__c and Fee__c are not directly related and each object is related to another custom object called "Permit__c" (kinda like a parent object so called), so I have created a junction object called "Deposit_And_Fee__c"
I have records for both Deposit and Fee objects and now the goal is I need to "AUTO" create Junction Object Deposit_And_Fee__c records coming from existing Deposit__c records and Fee__c records and keep creating junction object records everytime either deposit or fee record is created.
Also, Only Deposit records that have Fee records will be created (as both fields are required fields), but I need the solution to be smart enough to only search for Deposit records first, and look for the associated fee records.
(See below for illustration)
Trigger is what I think the correct way of solving my problem. If anyone can give a help or hint on how to get the list records or come up with full solution... very much appreciated...

User-added image
Deposit and Fee list view