Giter Club home page Giter Club logo

php-crm-toolkit's Introduction

php-crm-toolkit

CRM Toolkit for PHP provides integration with Microsoft Dynamics CRM in PHP applications.

This toolkit supports only Dynamics 365 SOAP interface. For PHP implementation of the Dynamics 365 Web API, see dynamics-webapi-toolkit project.

Installation

Install the latest version with

$ composer require alexacrm/php-crm-toolkit:dev-master

Examples

/**
 * 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;

$contactId = '1d2fc62f-1c56-448b-b546-edfb6d6fec5c';
/* 
* WS-Trust is now deprecated 

$options = [
    'serverUrl' => 'https://org.crmN.dynamics.com',
    'username' => '[email protected]',
    'password' => 'portalPassword',
    'authMode' => 'OnlineFederation',
];

$serviceSettings = new Settings( $options );

*/

$options = [
	'serverUrl' => 'https://org.crmN.dynamics.com',
	'applicationId' => '1111c62f-dead-beef-dead-edfbffffec5c',
	'clientSecret' => 'whateveristhesecretgenerated',
	'authMode' => 'OnlineFederation',
	'authMethod' => 'sharedSecretAuth',
	'cache' => new AlexaCRM\CRMToolkit\NullCache(),
];

// This code uses NullCache which allows to connect and run the operations 
// but it is very inefficient and should not be used in production. 
// You can use any PSR-6 compliant cache implementation. 
$serviceSettings = new OnlineS2SSecretAuthenticationSettings( $options );
$service = new OrganizationService( $serviceSettings );

// retrieve a contact and update its fields
$contact = $service->entity( 'contact', $guid );
$contact->firstname = explode( '@', $contact->emailaddress1 )[0];
$contact->update();
printf( 'Info for %s %s updated.', $contact->firstname, $contact->lastname );

// create a new contact
$contact = $service->entity( 'contact' );
$contact->firstname = 'John';
$contact->lastname = 'Doe';
$contact->emailaddress1 = '[email protected]';
$contactId = $contact->create();

// delete a contact
$contact->delete();

// execute an action
$whoAmIResponse = $service->executeAction( 'WhoAmI' );
echo 'Organization ID: ' . $whoAmIResponse->OrganizationId;

// inject cache repo
// must be instance of AlexaCRM\CRMToolkit\CacheInterface
$cacheRepo = Cache::instance();
$service = new Client( $serviceSettings, $cacheRepo );

In /examples/ you can find a few examples of toolkit usage. Copy config.example.php to config.php, set up credentials for your CRM and you are ready to go!

Contributing

Pull requests are gladly accepted in the GitHub repository.

License

Copyright (c) 2016 AlexaCRM.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Lesser Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

php-crm-toolkit's People

Contributors

billstennett avatar cburschka-pwc avatar georged avatar kevinbaland avatar mrudov avatar wizardist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-crm-toolkit's Issues

SoapFault exception: [s:Sender] An error occurred when verifying security for the message

Hi,
When trying to connect to the crm api, I'm getting the error

SoapFault exception: [s:Sender] An error occurred when verifying security for the message. in /var/www/local-api.cskout.com/vendor/alexacrm/php-crm-toolkit/src/Client.php:1311
Stack trace:
#0 /var/www/local-api.cskout.com/vendor/alexacrm/php-crm-toolkit/src/Client.php(1056): AlexaCRM\CRMToolkit\Client::getSoapResponse('https://disco.c...', '<s:Envelope xml...')
#1 /var/www/local-api.cskout.com/vendor/alexacrm/php-crm-toolkit/src/Client.php(1104): AlexaCRM\CRMToolkit\Client->retrieveOrganizations()
#2 /var/www/local-api.cskout.com/vendor/alexacrm/php-crm-toolkit/src/Client.php(183): AlexaCRM\CRMToolkit\Client->retrieveOrganization('https://growthe...')
#3 /var/www/local-api.cskout.com/library/Connectors/Connectors/MicrosoftDynamicsConnector.php(74): AlexaCRM\CRMToolkit\Client->__construct(Object(AlexaCRM\CRMToolkit\Settings))
#4 /var/www/local-api.cskout.com/library/Connectors/Connectors/MicrosoftDynamicsConnector.php(152): Crowdskout\Api\Connectors\Connectors\MicrosoftDynamicsConnector->authenticate()```

Could you offer any pointers on what I could be doing wrong that is causing this error?

WEEK_IN_SECONDS not defined

Hello,

We using php-crm-toolkit with a cache defined, i get an error because the constant WEEK_IN_SECONDS is not defined.
It looks like it is a wordpress constant but we are not using the library in a wordpress environment.

Could you please add this variable directly in the library?

Best regards

Mathieu

Get all contacts

How do i get all contacts? And can i filter on lists or something?

Setting 'statuscode' throws exception

In attempting to set 'statuscode' as 'Complete' on a task entity, an exception is thrown:

[Exception]
Unable to retrieve data from Dynamics CRM

In my example, the following code is used for creating the task entity:

private function addTask( $entity, $data, $entityType, $taskDetail, $taskFields = [] ) {

	$id                      = $entity->ID;
	$task                    = $this->dynamics->getEntity( 'task' );
	$task->subject           = $this->getEmailSubject( $data );
	$task->regardingobjectid = $entity;
	$task->scheduledstart    = $data->timestamp;

	$task->statuscode = 5; // This line cause the issue 

	//print_r( $task->attributes['statuscode'] );
	$taskDescription = $taskDetail . "\n" . $this->getEmailSubject( $data ) . "\n";
	foreach ( $taskFields as $taskField ) {
		$taskDescription .= $taskField . ": " . $data->$taskField . "\n";
	}
	$task->description = $taskDescription;

	return $task->create();
}

If the line:
$task->statuscode = 5; // This line cause the issue
is removed, the task entity is created without issue.

Changing the line to:
$task->statuscode = 'Complete';
continues to cause the same issue

The attribute details specify that the option is valid for update:

AlexaCRM\CRMToolkit\Entity\Attribute Object
(
    [logicalName] => statuscode
    [label] => Status Reason
    [description] => Select the task's status.
    [format] => 
    [maxLength] => 0
    [isCustom] => 
    [imeMode] => 
    [isPrimaryId] => 
    [isPrimaryName] => 
    [type] => Status
    [isLookup] => 
    [isValidForCreate] => 1
    [isValidForUpdate] => 1
    [isValidForRead] => 1
    [requiredLevel] => None
    [attributeOf] => 
    [optionSet] => AlexaCRM\CRMToolkit\Entity\OptionSet Object
        (
            [name] => task_statuscode
            [type] => Status
            [displayName] => Reason for the status of the task.
            [description] => Reason for the status of the task.
            [options] => Array
                (
                    [2] => Not Started
                    [3] => In Progress
                    [4] => Waiting on someone else
                    [5] => Completed
                    [6] => Canceled
                    [7] => Deferred
                )

            [isGlobal] => 
        )

    [lookupTypes] => 
)

Issues with booleans

Similar to the Staus issue the Lable is being pushed up instead of the value, Also 0 is matched as null and not passed.

Would do a branch and PR but don't have access, could you either allow me to branch/PR or put in the following fix?

Note I'll prob have more going forward.

screen shot 2016-10-27 at 15 07 24

->update() causing soap error

#0 C:\WampDeveloper\Websites\ptl-link.dezrez.com\webroot\vendor\alexacrm\php-crm-toolkit\src\Client.php(2002): AlexaCRM\CRMToolkit\Client->getSoapResponse('https://testdez...', '<s:Envelope xml...')
#1 C:\WampDeveloper\Websites\ptl-link.dezrez.com\webroot\vendor\alexacrm\php-crm-toolkit\src\Client.php(1726): AlexaCRM\CRMToolkit\Client->attemptSoapResponse('organization', Object(Closure))
#2 C:\WampDeveloper\Websites\ptl-link.dezrez.com\webroot\vendor\alexacrm\php-crm-toolkit\src\Entity.php(457): AlexaCRM\CRMToolkit\Client->update(Object(AlexaCRM\CRMToolkit\Entity))

Any Ideas? I've literally followed your guide to the tee. I can read, create and delete just not update.

cli-contact example not working

When running the cli-contact with email as an argument, I get the following error:

PHP Catchable fatal error: Object of class AlexaCRM\CRMToolkit\KeyAttributes could not be converted to string in /php-crm-toolkit-master/src/Entity.php on line 1297

How to query an n:n relationship from Dynamics 365 using Alexa CRM toolkit

I am developing a wordpress web application and I would like to query a custom many to many relationship from Dynamics 365 using Alexa CRM toolkit.

In fact, I have created a custom Entity called "Working Committees" ( many-to-many relationship with the Entity "Contacts").

I've already created the navigation form displaying contact information and in which I have used these Entities (Screenshot attached).

So, how is It possible to add a new "Working committee" to an existing "Contact" programmatically with PHP ?

Thank you in advance !

screen_stackoverflow

Get all invoices for specific contact

I'm working on script that bring me results of all invoices for specific contact ,the following script show the last ten invoices but for different contacts .

`$invoices = $service->retrieveMultipleEntities("invoice", $allPages = false, $pagingCookie = null, $limitCount = 10, $pageNumber = 1, $simpleMode = false);
foreach ($invoices->Entities as $invoice) {

  echo 'ID : ' . $invoice->ID . '<br>';

  echo 'Name :' . $invoice->name. '<br>';

  }` 

InvalidSecurity Error - retrive

Hi Everyone,

I get this return from CRM Dynamics:
<s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> <s:header> <a:action s:mustunderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:action> </s:header> <s:body> <s:fault> <s:code> <s:value>s:Sender</s:value> <s:subcode> <s:value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</s:value> </s:subcode> </s:code> <s:reason> <s:text xml:lang="en-US">An error occurred when verifying security for the message.</s:text> </s:reason> </s:fault> </s:body> </s:envelope>

The request sent:
<?xml version="1.0" encoding="UTF-8"?> <s:envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:header xmlns:default="http://www.w3.org/2001/04/xmlenc#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <a:action s:mustunderstand="1">http://schemas.microsoft.com/xrm/2011/Contracts/Discovery/IDiscoveryService/Execute</a:action> <sdkclientversion xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">8.1.0.383</sdkclientversion> <usertype xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">CrmUser</usertype> <a:replyto> <a:address>http://www.w3.org/2005/08/addressing/anonymous</a:address> </a:replyto> <a:messageid>urn:uuid:631344E3-ACD2-6742-4C74-62D5030B026D</a:messageid> <a:to s:mustunderstand="1">https://disco.crm2.dynamics.com/XRMServices/2011/Discovery.svc</a:to> <o:security s:mustunderstand="1"> <u:timestamp u:id="_0"> <u:created>2017-11-09T10:38:31.00Z</u:created> <u:expires>2017-11-09T10:43:31.00Z</u:expires> </u:timestamp> <default:encrypteddata xmlns="http://www.w3.org/2001/04/xmlenc#" id="Assertion0" type="http://www.w3.org/2001/04/xmlenc#Element"> <default:encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"> <ds:keyinfo> <default:encryptedkey> <default:encryptionmethod algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"> <ds:keyinfo id="keyinfo"> <o:securitytokenreference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <o:keyidentifier encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" valuetype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier"> (hidden)</o:keyidentifier> </o:securitytokenreference> </ds:keyinfo> <default:cipherdata> <default:ciphervalue>(hidden)</default:ciphervalue> </default:cipherdata> </default:encryptionmethod> </default:encryptedkey> </ds:keyinfo> <default:cipherdata> <default:ciphervalue>(hidden)</default:ciphervalue> </default:cipherdata> </default:encryptionmethod> </default:encrypteddata> </o:security> </s:header> <s:body> <execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Discovery" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <request i:type="RetrieveOrganizationsRequest"> <accesstype>Default</accesstype> <release>Current</release> </request> </execute> </s:body> </s:envelope>

Can anyone help me?

Thanks a lot!

Disabling verifyhost is causing a cURL failure

We're getting a cURL Error: Server aborted the SSL handshake while trying to authenticate (federated IFD). Some investigation tracked it down to the curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYHOST, 0 ); line added to Client::getSoapResponse() by 4b1f1d8.

Removing this line makes the SSL handshake work correctly.

Is it possible this is a bug in the code? I see that in other places, this option was only set depending on $this->settings->ignoreSslErrors, but in this function it is set unconditionally.

Add/Update values in OptionSet type field like Industry field in Accounts module

Hi,

I am trying to add/update the OptionSet value Like 'Industry' in Accounts module but it is not working. Can you please help with the syntax of adding/Updating value of Industry in Accounts module?
Here is my script:

$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );
$account = $service->entity( 'account' );
$account->name = 'ABC Account';
...
...
$account->industrycode= '2';

Thanks!

Class Psr\Log\NullLogger not found

Hi team,

first of all applogies because this will be a newbie question.

I've just downloaded your package and entered the configuration values for my on-premise CRM server in the examlple you give in your README.md.

But I receive the error:
Fatal error: Uncaught Error: Class 'Psr\Log\NullLogger' not found in C:\wamp64\www\eww\crm\AlexaCRM\src\Client.php on line 141

I'm not to big with this namespace thing but it seems to me that the Psr\Log\Nullogger class is missing.

What did I do wrong?

Regards,
Edgar

How to Search by fields

I need to search on content filtered by a specific field (which is not the ID).

I have tried using "KeyAttributes".
If I use the ID as keyAtribute, I get 1 result.
But if I use another field, it does not bring me results well.

I used the example "cli-contact.php" as a base

$ contactKey = new \ AlexaCRM \ CRMToolkit \ KeyAttributes ();
$ contactKey-> add ('emailaddress1', $ contactKeyValue);

This is my code:

$listFilterKey = "listname";
$listFilterValue = "example list 1";

$searchKeyToSearch = new \AlexaCRM\CRMToolkit\KeyAttributes();
$searchKeyToSearch->add( $listFilterKey, $listFilterValue);
 
$resultSearch = $dynamicsClient->entity( 'list', $searchKeyToSearch);
 
if ( !$resultSearch->exists ) {
 echo("List filtered by [".$listFilterKey."] = [".$listFilterValue."] <b>NO RESULTS</b>");
} else {
 echo("RESULTS");
}

Thanks!!

Error adding new Product

Hi,

I am trying to add new products and while I use this script I get the error:
Fatal error: Uncaught SoapFault exception: [-2147206390] The unit schedule id is missing.
Please help me point out where I am wrong.
Thanks!
Here is the script:

<?php
/**
 * Use init.php if you didn't install the package via Composer
 */
require_once 'getArray.php';
require_once '../vendor/autoload.php';
require_once '../vendor/alexacrm/php-crm-toolkit/init.php';
require_once 'config.php';
require_once 'includes/dynamicsLib.php';
require_once('includes/db.php');
$options 	= getAuth();
$data 		= getProductsArray($fileName);
//echo '<pre>'; print_r($data); //die('WWW');
$count = count($data);

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

$clientOptions = getAuth();


for($i=1; $i<$count; $i++){
	$serviceSettings = new Settings( $options ); 
	$service = new OrganizationService( $serviceSettings );

	$clientSettings = new Settings($clientOptions);
	$client = new Client($clientSettings);
	$metadata = MetadataCollection::instance($client);
	$product = $service->entity( 'product' ); //CREATE A NEW ACCOUNT	
		$parentProduct = $client->entity( 'product');
		$parentProduct->ID = $data[$i]['Parent'];
		$product->parentproductid = $parentProduct;

		$product->defaultuomscheduleid 		= 'Default Unit';
		$product->productstructure 		= $data[$i]['ProductStructure'];
		$product->name 					= $data[$i]['Name'];
		$product->productnumber 		= $data[$i]['ProductId'];
	
		$Id = $product->create(); //CREATE NEW
		echo 'Id: '.$Id;
	}
?>

Unable to get entity 'contact' using emailaddress1

i am trying to get contact entity using emailaddress1. But this is not able to get contact details using emailaddress1. However GUID works.

contact entity with emailaddress1('[email protected]') is there.

$contactKeyValue = '[email protected]';
    if ( filter_var( $contactKeyValue, FILTER_VALIDATE_EMAIL ) ) {
        $isRetrievedByEmail = true;
    }
if ( $isRetrievedByEmail ) {
    $contactKey = new \AlexaCRM\CRMToolkit\KeyAttributes();
    $contactKey->add( 'emailaddress1', $contactKeyValue );
}
$contact = $client->entity( 'contact', $contactKey);

Output: Contact not found. Aborting...

Notice: Undefined index: PWD

Whenever I run my code in cli mode I get the following notice:

Notice: Undefined index: PWD in ...\vendor\alexacrm\php-crm-toolkit\src\AbstractClient.php on line 101

This is due to this piece of code from the AbstractClient class

$requestDependentData = [
       $_SERVER['PWD'],
];

What is expected to be in that variable ?
It seems to work perfectly without any value, wouldn't it be better to check whether or not the variable is defined or not.

Best regards

Mathieu

Issues with RelationShip (PartyList) Fields Not linking correctly

So far I have found 2 main types of relationship fields in dynamics these are LookUps, and PartyLists. The first works when you simply attach the entity as the value, the second is treated in exactly the same way in the code but the link is not created.

In this case is specifically for linking Calls to Contacts.

So I’ve been trying to debug this issue;

Please see the difference I’ve found between what the CRM produced when using the fields and what the framework produces.

JSON produced by Dynamics CRM

regardingobjectid (Type: LookUp)
regardingobjectid":{"_visible":"inline-block","_noread":"none","value":"Gecko Labs","oid":"{F80F4224-2974-E611-80EF-5065F38B6471 }

to (Type: PartyList)
[{"_visible":"inline","_noread":"none","value":"A main","oid":"{A8B4DA36-759B-E611-80F3-5065F38BD531 }","activitypartyid":"{7D90DB59-43A0-E611-80E9-5065F38AEA21}","otype":"2","img":"/_imgs/ico_16_2.gif ?ver=1303141240","otypename":"contact","style":"ms-crm-Lookup-Item","isprocessenabled":"True","callback":"openlui(new Sys.UI.DomEvent(event))"}]

XML call produced by framework

to (Type: PartyList)
<b:KeyValuePairOfstringanyType>
<c:key>to</c:key>
<c:value i:type="b:EntityReference">
<b:Id>a8b4da36-759b-e611-80f3-5065f38bd531</b:Id>
<b:LogicalName>contact</b:LogicalName>
<b:Name i:nil="true" />
</c:value>
</b:KeyValuePairOfstringanyType>

regardingobjectid (Type: LookUp)
<b:KeyValuePairOfstringanyType>
<c:key>regardingobjectid</c:key>
<c:value i:type="b:EntityReference">
<b:Id>a8b4da36-759b-e611-80f3-5065f38bd531</b:Id>
<b:LogicalName>contact</b:LogicalName>
<b:Name i:nil="true" />
</c:value>
</b:KeyValuePairOfstringanyType>

to (Type: PartyList)
screen shot 2016-11-02 at 10 39 49

regardingobjectid (Type: LookUp)
screen shot 2016-11-02 at 10 40 25

Entity image

Hi!

How can I send image? - "entityimage"
Maybe example?

Thank you!

How call crm function

How call a crm function and return RetrieveMultiple.

In an example that someone sent me:

var fwdFilter = "pg_DataRVPSet?$select=pg_DatasRVPId&$filter=pg_ClienteId/Id eq guid'" + accountId + "'";
var oDataEndpointUrl = serverUrl + "/XRMServices/2011/OrganizationData.svc/" + fwdFilter
..
..

How can I use php-crm-toolkit to call "pg_DataRVPSet"

Issue with some Drop down Field types (status)

Entity.php line 641
When you have a $propertyDetails->type = 'status'
The OptionSet Label is passed through to the API SOAP Call instead of the value. This cause a SOAP fault as an integer not a string is expected;

"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'There was an error deserializing the object of type Microsoft.Xrm.Sdk.Entity. The value 'New Enquiry' cannot be parsed as the type 'Int32'.'. Please see InnerException for more details. in xxxxxx/vendor/alexacrm/php-crm-toolkit/src/Client.php:1202"

' Could not retrieve WSDL' locally

Hello, I get this error when I test cli-getallcontacts.php locally :
Fatal error: Uncaught Exception: Could not retrieve WSDL at https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc?wsdl in C:\wamp64\www\essenscia\vendor\alexacrm\php-crm-toolkit\src\Client.php on line 1978
However, the script is working fine when I test it on an online server. Any idea of what's happening ?

Adding a contact to a marketing list

I am trying to add a contact to a marketing list using the contact GUID.

I am able to get a list object from CRM using he following code:

$list = $service->entity( 'list', $listguid ); where $listguid is the guid of the marketing list I want to work with

but I'm not sure if this is the right approach. I suspect this only allows me to manipulate the list itself as opposed to adding contacts to it.

Can i use the AddListMembersListRequest function which looks to take a listguid and conatct guids as parameters? The problem is that I have no idea how to call a function like this using the php toolkit

I'd appreciate any advice on how to approach this problem.

I'm wondering if the executeAction method might be the way to go? Somethng like:

$result = $service->executeAction('AddListMembersList' $listguid ,$memberid); (which doesn't work as I've written it but somehow seems close).

Cheers,

Bill

Boolean fields don't update with false option

Hello, thanks for the toolkit, I find it really useful and use it all the time.

I recently came across an issue whereby I couldn't get Boolean fields to update in Dynamics to show the false option as selected, I could only ever successfully select the true option.

I've found a fairly simple fix for this and created a PR, I'd be grateful if you could have a look at it.

Many thanks

Donald

Couldn't authenticate with UserNameWSTrustBinding_IWSTrust13Async in "Federation" mode

Somehow my on premise setup wouldn't connect with the URI returned by this function in Client.php

protected function getTrust13UsernameAddress( DOMDocument $authenticationDOM ) { return $this->getTrustAddress( $authenticationDOM, 'UserNameWSTrustBinding_IWSTrust13Async' ); }

But it did start to work when I changed it for "UserNameWSTrustBinding_IWSTrust13Async2" (which uses trust/13/usernamemixed)

error when i connect

Federation and OnlineFederation both gave me same error :(
serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );

Could not find definition of Service in provided WSDL

Property of the entity cannot be set

Please i am trying to save a new contact into CRM Dynamics 365 but i am getting this error.
I am sure the error is as a result of something that i am not doing right.

errorcrm

How to set lookup fields

How can you set a lookup field value when creating a record?

Try creating a new entity record and insert the contact search value
The record was created, but the lookup field is still empty
where is my mistake

$client = new Client( $clientSettings );
$metadata = MetadataCollection::instance( $client );
$new = $client->entity( 'new_testentity');
$new->new_testentity_name = 'testname'; //textfield
$new->new_testentity_contact = $contactguid; //contact lookup
$newdata = $new->create();

Success Response too slow after creating lead

I used the php-crm-toolkit for creating new leads in the CRM. It was integrated in my ajax contact form. Everything is working fine. Data is sent to the CRM but the only problem is that it takes too long for the success response. It takes around 40 seconds to complete. Should it be this slow?? Are there any ways to speed this ?
screenshot from 2017-11-02 17-55-20

Need to update/add value of custom fields of leads on Dynamic CRM using create() or update() of Alexa CRM.

We have integrated Dynamic CRM using Alexa CRM PHP Toolkit ( https://github.com/AlexaCRM/php-crm-toolkit ).

Now, we need to Create/update Leads from our site to Dynamic CRM. We have tried to create/update Leads as per example shown on GitHub ( https://www.screencast.com/t/uRJrSe11CeC ).
But, by this way, we are facing problem to add our custom fields value on Dynamic CRM particular Leads. ( https://www.screencast.com/t/HzhwnxBxX8c ). We have created and added it's from here ( https://www.screencast.com/t/SatWiD9bifAW , https://www.screencast.com/t/h2vnDXbwoqEU ).

When we add leads using create() function at that time lead is created successfully and also our data added successfully to related fields like name, mobile_no., email_address etc. But our custom fields take its default value rather than our data which passed to create() function.
Also, When we tried to update using update() function it's not working even for its core fields (https://www.screencast.com/t/nvlgbn6qm9UE) .

So, could anyone please guide us to create or update Lead on Dynamic CRM using Alexa CRM PHP Toolkit?

Setting Lookup Fields - Guidance needed

First of all I wanted to thank you for this very helpful project, it makes the whole Dynamics CRM communication a lot easier!

I successfully tested and implemented the code to create and update a new contact (lead in my case).

The only thing I'm missing now is 'to set lookup values', which should be retrieved as GUID from the org.

I did not find an example howto achieve this task, so I was hoping that someone would be so nice to show me / point me to right implementation.

Thanks in advance!

Trying to get All Cases for specific contact and all notes for specific case

I have been trying to get all cases for specific contact but i got no success.

Here is my code:

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

Another similar problem when I am trying to get all notes(annotation) for specific case.
Here is my code:

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

Please help me. I have been trying this for last one month.

Undefined property via __get()

I'm getting a next error on run create() method of a custom entity.

"Undefined property via __get(): attributes in vendor/alexacrm/php-crm-toolkit/src/Entity.php on line 561"

That error only occours in this entity. in lead or contract works fine.

         $paymentEntity = $this->client->entity('custom_payments');
         $paymentEntity->edirect_amount = 1100;
         return $paymentEntity->create();

Set new object property with dynamics 365 using Alexa CRM toolkit

I'm using AlexaCRM Toolkit for Dynamics 365, I added a new field for the entity lead with the name new_wordpressid so i can do the mapping with the lead created in wordoress and the lead in dynamics 365 , so when i want to create a new lead using the following code lines

$lead= $service->entity('lead'); $lead->firstname = 'john'; $lead->lastname= 'do'; $lead->new_wordpressid = '555'; $lead->create();

i get the following error :
Undefined property via __set() - lead does not support property: new_wordpressid in
/var/www/clients/client348/web348/web/wp-content/plugins/dynamics-amcham-crm/dynamics-amcham-crm.php on line 41 in
/var/www/clients/client348/web348/web/wp-content/plugins/integration-dynamics/vendor/alexacrm/php-crm-toolkit/src/Entity.php on line 261

Adding the new wordpress_id Causes an error. How can i set the wordpress_id Without having Any errors.
Thank you for your support and interaction

Cache system | Out-of-the-box testing

Upon testing the toolkit furthermore, we successfully implemented it using the README.md example code.
Aside from the variable $contactId that is set at the start yet unused, the rest worked flawlessly.

At the end of the example, there is a snippet about a cache system that we do not understand properly and it generates the following error.
Fatal error: Class 'Cache' not found in /home/magikweb/public_html/dev/d365/oauth2/index.php on line 41

cache-repo

Are we missing something? Or that is an example that is not supposed to work unless certain conditions are met?

Entity reference protected?

Hi There,

I'm accessing a lead inside CRM, I'm trying to hit an entity reference on a field called referral manager which is a lookup for a user but it is protected.

When I variable dump the field

$lead->referralmanager

It pumps out this.

object(AlexaCRM\CRMToolkit\Entity\EntityReference)#23660 (4) {
["entityLogicalName":protected]=>
string(10) "systemuser"
["entityID":protected]=>
string(36) "f3a7aa9e-9889-e711-80d5-005056b21276"
["displayName":protected]=>
string(21) "Test Referral Manager"
["keyAttributes":protected]=>
array(0) {
}
}

Is there a separate function or method I need to perform in order to be able to access that protected data?

Working without composer

Without composer, we tried following statement:
In /examples/ you can find a few examples of toolkit usage. Copy config.example.php to config.php, set up credentials for your CRM and you are ready to go!

Doing so ends up with the following error:
Fatal error: Class 'Psr\Log\NullLogger' not found in /home/magikweb/public_html/dev/d365/oauth2/php-crm-toolkit/src/Client.php on line 137

I am not familiar with either composer or namespaces in general, but maybe there's a lacking inclusion assuming we're not using the autoloader?

App authentication

Is there a way to authenticate as an app using administrator consent has shown below with your toolkit?

I would like to authenticate one time and keep the refresh token for further use to avoid user authentication as explained in your examples.

Thank you for any follow-up.

image 40

File uploading with Notes(annotation)

I have been trying to upload attachment with notes(annotation).
Here is what i have been trying:

$case = $client->entity( 'incident', $contactKey);
if($case->exists)
{
    $annotation = $client->entity( 'annotation');
    $annotation->objectid=$case;
    $annotation->notetext=$note;
    if(isset($_FILES['test_file']))
    {
         $annotation->filename=$_FILES['test_file']['name'];
         $annotation->filedata=$_FILES['test_file']['tmp_name'];
         $annotation->filesize=$_FILES['test_file']['size'];
         $annotation->userFile=$_FILES['test_file'];
    }
    $annotation->subject=$note_title;
    $annotationId= $annotation->create();

    echo json_encode(array('status'=>0,'results'=>$annotationId,'message'=>'Note Created successfully!'));exit;
   
} 

Can you help me with this ?
Thanks...

Issue with onsite (non dynamics.com url) installations.

Onsite installations (non dynamics.com url's) are not supported but look like they could be with some work.

For example with an onsite installation with the url 'subdomain.domain.ac.uk' the organizationUrl gets built out as;
https://subdomain.api.domain.dynamics.com/XRMServices/2011/Organization.svc
Here as it should be;
https://subdomain.domain.ac.uk/XrmServices/2011/Organization.svc

And the discoveryUrl gets built as;
https://disco.domain.dynamics.com/XRMServices/2011/Discovery.svc
Where it should be;
https://subdomain.domain.ac.uk/XrmServices/2011/Discovery.svc

See alexacrm/php-crm-toolkit/src/Settings.php around line 256 for url parsing.

Undefined Index PWD error

Hi there. This library is great. Thank you for making it, making my life easier for sure.

I got the following error:

Undefined index: PWD in /vendor/alexacrm/php-crm-toolkit/src/AbstractClient.php:101 Stack trace: #0 /vendor/alexacrm/php-crm-toolkit/src/AbstractClient.php(101): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', '...', 101, Array) #1 /vendor/alexacrm/php-crm-toolkit/src/Auth/OnlineFederation.php(211): AlexaCRM\CRMToolkit\AbstractClient::getUuid() #2 /vendor/alexacrm/php-crm-toolkit/src/Auth/OnlineFederation.php(149): AlexaCRM\CRMToolkit\Auth\OnlineFederation::getLoginXML('https://login.m...', 'crmna:dynamics....', 'username', 'password') #3 /vendor/alexacrm/php-crm-toolkit/src/Auth/OnlineFederation.php(108): AlexaCRM\CRMToolkit\Auth\OnlineFederation->requestSecurityToken('https://login.m...', 'crmna:dynamics....', 'username', 'password') #4 /vendor/alexacrm/php-crm-toolkit/src/Client.php(1053): AlexaCRM\CRMToolkit\Auth\OnlineFederation->getDiscoverySecurityToken() #5 /var/crowdskout/api-worker/vendor/alexacrm/php-crm-toolkit/src/Client.php(1105): AlexaCRM\CRMToolkit\Client->retrieveOrganizations() #6 /vendor/alexacrm/php-crm-toolkit/src/Client.php(183): AlexaCRM\CRMToolkit\Client->retrieveOrganization('https://...') #7 /library/Connectors/Connectors/MicrosoftDynamicsConnector.php(74): AlexaCRM\CRMToolkit\Client->__construct(Object(AlexaCRM\CRMToolkit\Settings))

I printed that $_SERVER var out, I don't see the PWD var. It looks to be a bunch of env file variables. maybe in our particular php Laravel project, our env does not appear to have PWD in it. So, I went ahead and changed the AbstractClient.php file var to a variable we do have in that config, REQUEST_TIME, and it now works. But that may not really be a permanent solution, for everyone.

The other thought I had on this is that when looking into the use of the $requestDependentData var, I see that its only really used to create a hash. For our particular situation we have multiple servers that could be running this code at the same time, and possibly creating the same hash since the PWD is the same for both servers. That is if we had that PWD var.

Anyway, just a suggestion, it may be worth changing that one var. Thanks again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.