-
I've tried several ways to assign a contactRole to a contact. The internal id value of the Contact Role is -10. I tried setting the contactrole when I create the contact, but it did not work, code: `$contact = new Contact();
I also tried the following code using ContactAccessRolesList to assign the role to the contact associated with the customer: `$role = new ContactAccessRoles(); $contactRolesList = new ContactAccessRolesList(); $customer = new Customer(); $request = new UpdateRequest(); The result of the above code is: Invalid role reference key -10 I know the internal id is -10. Any clues on how to assign the contact role to the contact via api? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
After posting this, I found the answer. In case someone needs to do this, here is the solution: `$role = new AttachContactReference(); $request = new AttachRequest(); |
Beta Was this translation helpful? Give feedback.
After posting this, I found the answer. In case someone needs to do this, here is the solution:
`$role = new AttachContactReference();
$role->attachTo = new RecordRef();
$role->attachTo->type = "customer";
$role->attachTo->internalId = 32258; //customer internal id
$role->contact = new RecordRef();
$role->contact->internalId = 55811; //contact internal id
$role->contactRole = new RecordRef();
$role->contactRole->internalId = "-10"; //contact role internal id
$request = new AttachRequest();
$request->attachReference = $role;
$response = $service->attach($request);`