Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example of request with expand? #60

Open
pixelpaulaus opened this issue May 6, 2021 · 2 comments
Open

example of request with expand? #60

pixelpaulaus opened this issue May 6, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@pixelpaulaus
Copy link

pixelpaulaus commented May 6, 2021

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 georged added the enhancement New feature or request label May 6, 2021
@georged
Copy link
Contributor

georged commented May 6, 2021

@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'].

public function getRecord( string $entityCollection, string $entityId, array $queryOptions = null ): object {

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.

@sawtell
Copy link

sawtell commented Dec 4, 2024

I have done some work to extend the package to support more advanced filtering and expands (among some other bits).
You can see the changes here: https://github.com/sawtell/dynamics-webapi-toolkit/tree/feature/filters-and-expands

The changes allow for the following:

$query = new QueryByAttribute('logical_name');
$query->ColumnSet = new ColumnSet(['name', 'email', ...etc]);
$query->ColumnSet->AddExpand('field_name', new ColumnSet(['attributes', 'here']));

Also for more advanced filtering:

// Filter where created at date is between two dates
$query->AddFilter(new Filter('created_at', ['2024-10-01', '2024-12-04'], 'Between'));

It would be good to contribute these changes back to the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants