AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Odata query parameters support (for Composable Functions)

dantol1 opened this issue · comments

Hi, is there a way to add odata parameter (such as filter/select) to functions requests?
I want to add a select clause to an unboundFunction but I don't see a way to add query parameters.

We're currently using version 1.7.9

Thanks!

@dantol1 hi!
You can use a regular retrieveRequest for that, if I understand you correctly. Let me know if you have an example. But by looking at the documentation:

const result = await dynamicsWebApi.retrieveRequest({
  collection: "systemusers",
  select: ["fullname", "systemuserid"],
  filter: "Microsoft.Dynamics.CRM.LastXHours(PropertyName=@p1,PropertyValue=@p2)",
  queryParams: ["@p1='modifiedon'", "@p2=12"]
});

Hope this helps.

Thank you

I think I didn't explain myself very well, I am trying to use the executeUnboundFunction method (in this specific case for RetrieveAadUserRoles) and add a ?$select=... to select only parts of the response.
As I understand the retrieveRequest is for querying a specific entity, right? So it won't work for an unbound function.

Sorry if my previous comment was unclear.

I see. I did not actually know that composable functions exist in Dynamics Web Api. I will need to add that.

Let me see if I can find a workaround for your case using current functionality.
Can you give me a full url (without org name) that you are trying to compose?
Thanks

I was trying to find a workaround for version 1.7.9, but could not because of a specific name check for a collection that I do inside DynamicsWebApi. I had to add an additional parameter skipNameCheck to a retrieveRequest to make it work in v.1.7.12. Hope you can upgrade to it. Here's an example:

const result = await dynamicsWebApi.retrieveRequest({
  collection: "Microsoft.Dynamics.CRM.RetrieveAadUserRoles",
  key: "DirectoryObjectId=@p1",
  select: ["name"],
  queryParams: ["@p1=e3713da3-9852-4f1d-be73-67872a4fc14b"],
  skipNameCheck: true // <-- this is required to make it work
});

You could potentially even write this (I haven't tested that):

const result = await dynamicsWebApi.retrieveRequest({
  collection: "Microsoft.Dynamics.CRM.RetrieveAadUserRoles",
  key: "DirectoryObjectId=e3713da3-9852-4f1d-be73-67872a4fc14b",
  select: ["name"],
  skipNameCheck: true // <-- this is required to make it work
});

Hope this helps!

I am closing this issue. If you have more questions feel free to add a comment in the same issue.