In Salesforce, for the junction record, let's call it Course_Registration__c
.
For each course registration (Contact : Course), you will need to insert a Course_Registration__c
with these fields filled in:
- Course__c (points at the Course being registered for)
- Contact__c (points at the Contact registered for the course)
Both Course_Registration__c.Course__c
and Course_Registration__c.Contact__c
are ID fields. The values to set will be the IDs returned after you insert the Course__c
and Contact
SObjects, respectively.
That is, the inserts to the two master SObjects need to happen first, you grab the IDs of these upon return from the insert call to the SFDC API, and you use them to populate a junction record via another insert (or bulk insert for all registrations per Contact)
manpreet
Best Answer
2 years ago
Before I begin my question, I'd just like to give a brief background on what I am doing and what I am looking to achieve.
FYI: I am a newbie with this Salesforce stuff.
I have connected my site with salesforce successfully via the Force.com PHP Toolkit.
VIA the PHP toolkit I am able to successfully upsert a contact when a new user is registered on my site.
I have created a custom object called "Courses".
VIA the PHP toolkit I am able to successfully upsert a "course" into the custom object "courses".
I am looking at creating a relationship between the 2 objects. The relationship will be contacts (students) assigned to (courses). A contact can be in many courses and a course can have many students.
So after some research I have found a way to create this many-to-many relationship via creating a junction object which will serve to connect the 2 other objects via the "Master-Detail Relationship" fields.
This is working fine as I want it. If I go into a contact I can see a section where I can assign a course to the contact.
I need the last step to be done via the PHP Toolkit.
This is where I do not know what to do or how to write the function. Because it is a many-to-many relationship, Im guessing that the object I build in php has to contain an array of courses that I am assigning to the contact.
Is there a particular field I need to target and if so what are the params I need to pass to it?