You need to sign in to do that
Don't have an account?
Andrew Morales 1
Write trigger to Create Junction Records After Upload
Creating Many to Many Relationships from a CSV
Hello!
I created the schema below with (two) Master Detail Fields on the Junction-Object-AB pointing to both A and B. I believe the schema is sound for my application since this is a Many to Many relationship.
Schema:
Standard Object A
Custom Object B
Junction Object AB
My question is related to uploading the data via csv. The data is coming from an internal database and each record has a unique ID (unique to the table) already so I dont have to worry about pulling back the SFDC ID after upload from the success file.
Where I am stuck is - on object B, within one record/line I have multiple record ID's in one cell pointing to the data in Object A. So an example would be:
Object A - Developer Contact
-- Tom Jones - ID - 1
-- Johnny Depp - ID - 2
-- Christina Aguilera - ID - 3
Object B - Applications
-- Angry Birds - Dev ID - 1,2,3
-- Tetris - Dev ID - 2,3
So I would need to create 3 junction records for Angry Birds and 2 junction records for Tetris based on the Developers that worked on them.
QUESTIONS
How can I create the junction records if all the ID's are in one cell?
Do all the ID's have to be loaded in a custom field and it has to be created via a trigger? (If so, some help articles or specific search topics would be appreciated. I am not a developer by trade)
I will be working with about 30K records for Object A and 30K for object B so this cannot be done manually. I would appreciate any suggestions and/or pointing me to some help articles so I can work through it.
THANK YOU!!!
Hello!
I created the schema below with (two) Master Detail Fields on the Junction-Object-AB pointing to both A and B. I believe the schema is sound for my application since this is a Many to Many relationship.
Schema:
Standard Object A
Custom Object B
Junction Object AB
My question is related to uploading the data via csv. The data is coming from an internal database and each record has a unique ID (unique to the table) already so I dont have to worry about pulling back the SFDC ID after upload from the success file.
Where I am stuck is - on object B, within one record/line I have multiple record ID's in one cell pointing to the data in Object A. So an example would be:
Object A - Developer Contact
-- Tom Jones - ID - 1
-- Johnny Depp - ID - 2
-- Christina Aguilera - ID - 3
Object B - Applications
-- Angry Birds - Dev ID - 1,2,3
-- Tetris - Dev ID - 2,3
So I would need to create 3 junction records for Angry Birds and 2 junction records for Tetris based on the Developers that worked on them.
QUESTIONS
How can I create the junction records if all the ID's are in one cell?
Do all the ID's have to be loaded in a custom field and it has to be created via a trigger? (If so, some help articles or specific search topics would be appreciated. I am not a developer by trade)
I will be working with about 30K records for Object A and 30K for object B so this cannot be done manually. I would appreciate any suggestions and/or pointing me to some help articles so I can work through it.
THANK YOU!!!
Please find the below trigger:
Here What I did is,
Standard Object - Account
Custom OBject - ObjectB
Junction Object - AccountObjBJunc
Created fields in Junction object:
Implemented the below trigger on ObjectB and considered an insert scenario.
Also tested the above trigger in my DE environment:
Results is:
Please do let me know if it helps you.
Regards,
Mahesh
What was the purpose of the AccountId_Values__c field and what object was it created on? Thank you very much for all the help.
ERROR: AddOnTrigger: execution of AfterInsertcaused by: System.StringException: Invalid id: 9External entry point
Any thoughts? Code is below. You can see my Objects are Contact, AddOn, Dev_AddOn(Junction)