如何使用php CRM工具包在Microsoft Dynamics Online CRM中创建案例或事件

如何使用php CRM工具包在Microsoft Dynamics Online CRM中创建案例或事件,php,dynamics-crm,crm,dynamics-crm-online,Php,Dynamics Crm,Crm,Dynamics Crm Online,我正在努力创造它给我的案例 致命错误:未捕获AlexaCRM\CRMToolkit\SoapFault:您应该指定父联系人或帐户。在第1159行的D:\wamp64\www\php\u crm\vendor\alexacrm\php crm toolkit\src\Client.php中 我的代码: <?php /** * Use init.php if you didn't install the package via Composer */ require_once 'vendo

我正在努力创造它给我的案例

致命错误:未捕获AlexaCRM\CRMToolkit\SoapFault:您应该指定父联系人或帐户。在第1159行的D:\wamp64\www\php\u crm\vendor\alexacrm\php crm toolkit\src\Client.php中

我的代码:

<?php
/**
 * Use init.php if you didn't install the package via Composer
 */
require_once 'vendor/autoload.php';

use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;



$options = [
    'serverUrl' => '**********************',
    'username' => '****************',
    'password' => '*************',
    'authMode' => '***********************',
];

$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );


// create a new contact
$incident = $service->entity( 'incident' );
$incident->title = 'Test Created With Proxy';
$incident->description = 'This is a test incident';
$incidentId = $incident->create();

?>

错误很明显,您必须提及事件的客户-父帐户或联系人。检查下面的代码,它应该工作不确定php语法

$incident = $service->entity( 'incident' );
$incident->title = 'Test Created With Proxy';
$incident->description = 'This is a test incident';
$incident->customerid = new EntityReference( 'contact', 'GUID HERE' );
$incidentId = $incident->create();
从上面的链接中,为查找字段分配添加另一个代码段:

$customer = $client->entity( 'contact' );
$customer->ID = 'GUID HERE';
$incident-> customerid = $customer;

最后,我使用以下代码创建了案例:

<?php
/**
 * Use init.php if you didn't install the package via Composer
 */
require_once 'vendor/autoload.php';

use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;
use AlexaCRM\CRMToolkit\Entity\EntityReference;

$options = [
    'serverUrl' => '**************************',
    'username' => '**********************',
    'password' => '*****************',
    'authMode' => 'OnlineFederation',
];


$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );

$contact = $service->entity( 'contact' );
$contact->firstname = 'John';
$contact->lastname = 'Doe';
$contact->emailaddress1 = 'john.doe@example.com';
$guid = $contact->create();

$incident = $service->entity('incident');
//echo '<pre>';print_r($incident);echo '</pre>';
$incident->title = 'Test Created With Proxy';
$incident->description = 'This is a test incident';
$incident->customerid = new EntityReference( 'contact', $guid );
//$incident->ID = $guid;//contactid responsiblecontactid primarycontactid
$incidentId = $incident->create();
?>

嗯,那你的问题是什么?您尝试了什么?我想创建客户服务-所有案例都使用php。我正在使用Thank Arun,您能告诉我如何获取吗?@PHPMagentoDeveloper guid是任何CRM记录的主键-基本上看起来像带破折号的32位数字。另外,我还收到了以下错误通知:未定义的属性通过uu集-事件不支持属性:D:\wamp64\www\php\u crm\test.php中的customerid\u联系人,位于第37行的D:\wamp64\www\php\u crm\vendor\alexacrm\php crm toolkit\src\Entity.php中264@PHPMagentoDeveloper真的很抱歉,我是凭记忆打的。。我也不确定您是否使用web api或odata api。尝试使用customeridThanks获取帮助,获得致命错误:未捕获错误:找不到类“EntityReference”