API Client
|
Most records in 1CRM have other related recors linked to them. For example, Contact can have a number of related accounts. To add a related record, use the Model::addRelated() method.
In the following example, we get a list of accounts related to a Contact, and add all those accounts to another contact:
This is the simplest form of using this method. You just pass an array of related record IDs in $data
parameter of Model::addRelated() method.
Some relationships between objects are more complex, they contain not only the ID of related records, but also additional relationship data. For example, Assembly can contain multiple Products, and for each product the relationship stores the quantity of the products in this assembly. For such relationships, you need to specify additional data: