Insert new contact

97 views Asked by At

I m using https://github.com/AlexaCRM/php-crm-toolkit to send data from a form to an entity in CRM I want to add a product id from entity 'new_produituic' to 'contact' entity

<?php 
require 'autoload.php' ;
use AlexaCRM\CRMToolkit\Entity\EntityReference;
use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;
$options = [
'serverUrl' => 'https://xxxx/',
              'username' => 'xxx',
              'password' => 'xxx',
              'authMode' => 'xxx',
              'ignoreSslErrors' => true

];
$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings ); 
$guid="00f1b74b-645c-e911-80c1-005056aa3849" ;   
$contact = $service->entity('contact');
 $contact->firstname='testproduits';
 $contact->new_produit_demande= new EntityReference('new_produituic',$guid);
 $contactId = $contact->create();

i m expecting to add a contact that the field first name is "testproduits" and the field "new_produit_demande" is the guid

1

There are 1 answers

1
Arun Vinoth-Precog Tech - MVP On

This is permission/privilege issue. The error saying 'Principal user (Id=0fdb9f17-4c5c-e911-80c1-005056aa3849, type=8) is missing prvAppendTonew_produituic privilege (Id=9f11bbd6-dcab-4764-9dbc-86fa5657f02a)' which means the user you are using 'username' => 'xxx', all of the security roles are missing AppendTo privilege on new_produituic Entity.

To compete this below step - you should have System Admin/Customizer role.

Go to any of the security role of that user which is a huge matrix, click the Custom entities tab, look for new_produituicEntity row and AppendTo column, if you keep clicking the small circle you can furnish the privilege like full green circle (whole org) of half orange (same BU) based on your need.

Read more