derekfinlinson / xrm-webapi Goto Github PK
View Code? Open in Web Editor NEWDynamics 365 Web Api TypeScript module
License: MIT License
Dynamics 365 Web Api TypeScript module
License: MIT License
It looks like reference to @types/xrm
is not actually used anywhere in the code, I believe reference to that module could be removed
Related to #2
In the xrm-webapi/src/xrm-webapi.ts file, there is a function called getNextPage() which says it implements paging for retrieveMultiple. However, when I look at retrieveMultiple, there is no reference to getNextPage() and paging doesn't seem to be implemented in a different way.
Hi!
I created an Angular SPA for D365. All works fine in Edge/Chrome but doesn't in IE.
I got SCRIP1002: Syntax error (some problem with class WebApiConfig).
Maybe you have some idea about how to fix it?
Hi!
As far as I understand in your design there is no method Retrieve Multiple for Soap request with FetchXml parameter.
I.e:
const options: string =
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"> <entity name="account"> <attribute name="name" /> <attribute name="accountid" /> <filter> <condition attribute="accountid" operator="eq" value={00000000-0000-0000-0000-000000000000}/> </filter> </entity> </fetch>
;
retrieveMultiple(config, 'accounts', options) .then(
(results) => {
const accounts: any[] = [];
for (const record of results.value) {
accounts.push(record);
}
console.log(accounts.length);
},
(error) => {
console.log(error);
}
);
Thanks for answer.
It would be nice to have CRM specific types be defined more strictly.
For example, OptionSetValue
, Money
or EntityReference
, etc.
Currently retrieve
and retrieveMultiple
accept empty query strings:
queryString?: string
Though, trying to pass empty query string user would get error, something like: Resource not found for the segment 'accountsundefined'
.
Given I want to select multiple gets in a batch operation ( and I have PR #24 ) I receive the error
Uncaught SyntaxError: Unexpected number in JSON at position 1
What I expect is an array which contains the result of each inner response body.
Steps to reproduce:
const changeSets: any[] = [];
const gets: string[] = [
"accounts?$select=name",
"accounts?$select=name"
];
batchOperation(config, "BATCH123", "CHANGESET123", changeSets, gets)
.then((result) => {
console.log(result);
}, (error) => {
console.log(error);
});
It appears xrm-webapi attempts to parse the entire response as JSON when first it should split and extract each individual response body first.
Example response from CRM that is passed to JSON.parse
--batchresponse_4534da94-ba24-4acb-b11e-3b35476dc3de
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Preference-Applied,OData-EntityId,Location,ETag,OData-Version,Content-Encoding,Transfer-Encoding,Content-Length,Retry-After
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context":"https://dynamics.com/api/data/v8.2/$metadata#accounts(name)","value":[
{
"@odata.etag":"W/\"1248759412\"","name":"Account 1","accountid":"00000000-0000-0000-0000-000000000000"
},{
"@odata.etag":"W/\"1248759537\"","name":"Account 2","accountid":"00000000-0000-0000-0000-000000000000"
}
]
}
--batchresponse_4534da94-ba24-4acb-b11e-3b35476dc3de
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Preference-Applied,OData-EntityId,Location,ETag,OData-Version,Content-Encoding,Transfer-Encoding,Content-Length,Retry-After
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context":"https://dynamics.com/api/data/v8.2/$metadata#accounts(name)","value":[
{
"@odata.etag":"W/\"1248759412\"","name":"Account 1","accountid":"00000000-0000-0000-0000-000000000000"
},{
"@odata.etag":"W/\"1248759537\"","name":"Account 2","accountid":"00000000-0000-0000-0000-000000000000"
}
]
}
--batchresponse_4534da94-ba24-4acb-b11e-3b35476dc3de--
The boundary separator can be extracted from the Content-Type
response header.
The response body should be split based on that.
Per response body, the initial Content-Type
and Content-Transfer-Encoding
headers should be stripped out.
The remaining HTTP headers should be parsed and checked ( e.g req.status >= 200) && (req.status < 300
)
If the response type is application/json
the body should then be parsed by JSON.parse.
Hi there,
i am currently using (trying to use) your npm package. Sadly there is a build error when i am using your npm package in my webressource (written in angular 4). The problem there seems to be the 'require("https")' in request.js.
It statens:
ERROR in ./node_modules/xrm-webapi/dist/request.js
Module not found: Error: Can't resolve 'https' in 'MY PATH....\node_modules\xrm-webapi\dist'
It does not seem to get the https reference which is definitly needed, when you use it as a regular npm import. I did not manage to make it work properly, so as i always use your code out of a 'window' i have simply removed the 'reuqire("https")' to make it buildable and workable. This means for me i only can use it from a webressource (which is totally fine, as i only am going to use it in this form), but i can not update this file atm, as it would update this file again. Maybe you can integrate my thought or process in future bug fixes or versions.
If my request is unclear, not enough specified or anything else, please let me know.
Best regards
Daniel
Is it possible to retrieve Metadata using the webapi, like EntityDefinitions, etc?
So since I haven't found a helper function for require is not a native function, at least not in browsers. It may work in nodejs though.
So this will not work unless you specify another dependency to a module loader.
var es6_promise_1 = require("es6-promise");
Based on the source code it seems that the batchOperation function can only create multiple records in bulk. For updating records it requires the HTTP PATCH method, currently it's set to POST: (
Line 705 in 66fb684
Is there a way to override this value or could it be that I have overlooked a configuration?
This line in particular:
const context = typeof GetGlobalContext != "undefined" ? GetGlobalContext() : Xrm.Page.context;
When I call this function from within CRM (using FF) I get error: ReferenceError: GetGlobalContext is not defined
.
Most likely in this case it's better to use Xrm.Page.context
instead.
I have fix, but from #8 experience some unwanted commits can sneak through, so I would give here function that I proposing to introduce to be more flexible in determining context:
private static getGlobalContext() {
// If script was called from CRM form Xrm.Page.context object is available
if (Xrm && Xrm.Page && Xrm.Page.context) {
return Xrm.Page.context;
}
// If script was called from custom web resource most likely GetGlobalContext() function is available.
// It would be able to provide script with needed context object.
if (typeof GetGlobalContext != "undefined") {
return GetGlobalContext();
}
throw Error("MS Dynamics CRM Page context was not found");
}
It would be nice to have room in Gitter
or Slack
for discussing xrm-webapi
enhancements.
master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can resolve this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
An npm token must be created and set in the NPM_TOKEN
environment variable on your CI environment.
Please make sure to create an npm token and to set it in the NPM_TOKEN
environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/
.
Good luck with your project β¨
Your semantic-release bot π¦π
Hello, does this work with offline capabilities xrm provides?
Please post some examples
Thanks.
ERROR in ./node_modules/xrm-webapi/dist/request.js
Module not found: Error: Can't resolve 'https' in 'C:\Angular Application\first-crm-angular-app\node_modules\xrm-webapi\dist'
Given I want to select multiple gets in a batch operation I receive the error
The message header '--batch_BATCH123' is invalid. The header value must be of the format '<header name>: <header value>'.
Steps to reproduce:
const changeSets: any[] = [];
const gets: string[] = [
"accounts?$select=name",
"accounts?$select=name"
];
batchOperation(config, "BATCH123", "CHANGESET123", changeSets, gets)
.then((result) => {
console.log(result);
}, (error) => {
console.log(error);
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.