使用ALEXACRM获取案例的所有注释(注释)

时间:2017-09-22 12:57:46

标签: php dynamics-crm dynamics-crm-2011 dynamics-crm-2013 dynamics-crm-online

我正在尝试获取特定案例(事件)的注释(注释)。 这是我的代码:

$incidentid= '49243f9c-548e-e711-80c6-000c2983dc59';


$clientOptions  = include( 'config.php' );
$clientSettings = new Settings( $clientOptions );
$client         = new Client( $clientSettings );
$metadata       = MetadataCollection::instance( $client );

    /* $incident = $client->entity( 'incident', $contactKeyvv); */
   $contactKey2 = new \AlexaCRM\CRMToolkit\Entity\EntityReference("incident");
    $contactKey2->__set("ID",$incidentid );

$notes = $client->entity('annotation', $contactKey2);
$isRetrievedByEmail = false;

echo "<pre>";
print_r($notes);
exit;

但我无法使用ALEXACRM获取这些详细信息。我做错了什么?

还尝试了类似于获取特定联系人的案例(事件)。但没有运气。这是代码:

$contactKey = new \AlexaCRM\CRMToolkit\KeyAttributes();
$contactKey->add( 'customerid','5e61e646-8c8c-e711-80c6-000c2983dc59' );
$contactKey->add( 'customeridtype',2);

$contact_cases = $client->entity( 'incident', $contactKey);
echo "<pre>";
print_r($contact_cases);exit;

如果有人试过这个,请帮帮我

1 个答案:

答案 0 :(得分:0)

以下是乔治GITHUB AlexaCRM的答案。

    $xml='<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="annotation">
    <attribute name="subject" />
    <attribute name="notetext" />
    <attribute name="filename" />
    <attribute name="createdon" />
    <attribute name="annotationid" />
    <order attribute="subject" descending="false" />
    <link-entity name="incident" from="incidentid" to="objectid" alias="ab">
      <filter type="and">
        <condition attribute="incidentid" operator="eq" uiname="abcdefg" uitype="incident" value="{'.$incidentid.'}" />
      </filter>
    </link-entity>
  </entity>
</fetch>';

$clientOptions  = include( 'config.php' );
$clientSettings = new Settings( $clientOptions );
$client         = new Client( $clientSettings );
$metadata       = MetadataCollection::instance( $client );

$incident = $client->entity( 'incident', $incidentid);
if($incident->exists)
{
$notes = $client->retrieveMultiple($xml,$allPages = true, $pagingCookie = null, $limitCount = null, $pageNumber = null, $simpleMode = true );


$abc=array();
foreach ($notes->Entities as $note) {


    $abc2['subject']=$note->subject;
    $abc2['notetext']=$note->notetext;

    $abc2['annotationid']=$note->annotationid;
    $abc2['date_time']=$note->createdon->FormattedValue;
    $abc2['date_time_YMD']=date("Y-m-d H:i:s",$note->createdon->Value);

    $abc[]=$abc2;


}