Setting relationship via SOAP: what goes where?

I need to set a 1-to-many relationship between a Document that I upload via the SOAP API and a custom module called ass_Assignments. I’m not quite sure what is supposed to go in the “link_field_name” or the “name_value_list” fields in the set_relation() call. I’ve looked at other examples such as Contacts and Opportunities in the docs, but those relationships don’t exist in the system I’m working on, so I can’t compare and contrast.

When I set a relation via the GUI, the table ass_assignments_documents_1_c gets updated, specifically the two fields ass_assignments_documents_1ass_assignments_ida (which holds the assignment ID) and ass_assignments_documents_1documents_idb (which holds the document id).

The tables are both have an “assignment_no” that exists in both tables.

The call I’m making now is this:


$result = $this->soapclient->set_relationships(
                            $this->sess_id,
                            "ass_Asignments",
                            $assignId,
                            "assignment_no",
                            array($docId),
                            array( ),              # what goes here?
                            0
                  );

When I run this, I get an “Invalid data sent” error.

What I don’t understand is what to put into the “link_field_name” and what goes in the “name_value_list”? Also, how does the system know I’m linking to a Document and not, say, an Opportunity.

The link_field_name is the name of the relationship between the two modules. You can get this by going into studio and looking at the relationship. “name_value_list” is for special cases only in the set_relationships call. Its for populating additional fields that exist in the relationship table between modules. ass_assignments_documents_1ass_assignments_ida and ass_assignments_documents_1documents_idb are normnal relationship fields and will be populated automatically so you can just ignore name_value_list in this case.

Thanks for the reply.

I did as you suggested to no avail. My code now reads as


        $result = $this->soapclient->set_relationships(
                            $this->sess_id,
                            "ass_Assignments",
                            $assignId,
                            "ass_assignments_documents_1",
                            array($docId),
                            array(),
                            0
                  );

and I am still getting “Invalid data sent”. I suspect there is some subtle nuance that I’m missing and that the error message is bogus. PHP’s SOAP has lied to me before in this project.

BTW, I sent you a message via your contact form.

Found my problem and now the relationship is getting set (I hope properly).

The problem? I was reading the docs for set_relationship() but calling the function set_relationshipS().

I hate computers.