How To Create a case Or Incident In Microsoft Dyna

2019-08-23 21:10发布

I am trying to create case it's giving me

"Fatal error: Uncaught AlexaCRM\CRMToolkit\SoapFault: You should specify a parent contact or account. in D:\wamp64\www\php_crm\vendor\alexacrm\php-crm-toolkit\src\Client.php on line 1159"

My code:

<?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();

?>

2条回答
贪生不怕死
2楼-- · 2019-08-23 21:37

Finally I created case by using following code:

<?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();
?>
查看更多
The star\"
3楼-- · 2019-08-23 21:44

The error is very clear, you must mention the customer of the incident - Parent account or contact. Check the below code, it should work (not sure about php syntax).

$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();

Reference

From the above link, adding another snippet for lookup field assignment:

$customer = $client->entity( 'contact' );
$customer->ID = 'GUID HERE';
$incident-> customerid = $customer;
查看更多
登录 后发表回答