XRM-OSS / Xrm-WebApi-Client

A promise-based JavaScript library for the Microsoft Dynamics CRM WebApi - TypeScript type definitions available
https://xrm-oss.github.io/Xrm-WebApi-Client/
MIT License
100 stars 28 forks source link

Can't create RetrievePrincipalAccessRequest with typescript #36

Closed methodnumber13 closed 5 years ago

methodnumber13 commented 5 years ago

I'm trying to make request with typescript like this: try { let req = new webapi.Requests.RetrievePrincipalAccessRequest() .with({ entityName: 'systemuser', entityId: toTrimBrackets(parent.Xrm.Page.context.userSettings.userId), urlParams: { Target:{"@odata.id": "accounts('${id}')"}` } }); console.log(req); webapi.Execute(req) .then((result: any) => { console.log(result); });

} 
catch (e) {console.error(e)}`

and I got this error image

Also, I tried to write it like let req = webapi.Requests.RetrievePrincipalAccessRequest; req.prototype.with({///my code here}) and I got another error image Could you provide any samples how I can make my request correctly?

P.S.: I have already seen an implementation with JS from this link https://github.com/DigitalFlow/Xrm-WebApi-Client/wiki/Implemented-WebApi-Requests but it's not working in TS

DigitalFlow commented 5 years ago

Hi @methodnumber13,

Thanks for reaching out. Can you please try leaving out the "new" in front of the request and not appending the parentheses, so that it looks like this: let req = webapi.Requests.RetrievePrincipalAccessRequest.with(...)

The requests are not regular classes, they are objects which get their messages and properties by protoypal inheritance.

Kind Regards, Florian

DigitalFlow commented 5 years ago

Hi @methodnumber13,

I'll close this issue for now, if above fix does not solve your issue, please reopen again.

Kind Regards, Florian