AlexaCRM / dynamics-webapi-toolkit

Dynamics 365 Web API Toolkit for PHP
MIT License
75 stars 58 forks source link

example of request with expand? #60

Open pixelpaulaus opened 3 years ago

pixelpaulaus commented 3 years ago

Hello, I am trying to do a request on an account, and expand some of the account records. when i communicate with the API via another method/wrapper i have been using, i can do so by adding in:

expand: [{ property: 'property name', select: ['*'] }]

But i am not sure how to add in the expand code for the request:

$retrievedContact = $client->Retrieve( 'account', 'IDHERE', new \AlexaCRM\Xrm\ColumnSet( true ));

could you please provide an example, i want to expand multiple account properties to be retrieved in one request.

georged commented 3 years ago

@pixelpaulaus

I don't know what another method/wrapper you've been using so I can't comment on that. Can you provide a reference?

We do not provide expand on the Client class level. If you want, you can use OData client (available via $odataClient = $client->getClient() ). OData client includes getRecord method with queryOptions as a parameter; you can assign your expand expression to $queryOptions['Expand']. https://github.com/AlexaCRM/dynamics-webapi-toolkit/blob/6618df0906c64ef23de9227760bd67d07508d39f/src/WebAPI/OData/Client.php#L396

But then you're on your own to deal with what's coming back.

Having said that, it's not a bad idea. It'd be easy to add that option to the method itself but I think deserialization would need some work.