Git Product home page Git Product logo

xrm-webapi's People

Contributors

azure-pipelines[bot] avatar cjsewell avatar dependabot[bot] avatar derekfinlinson avatar gitter-badger avatar shytikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xrm-webapi's Issues

Remove unused dependenceis

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

Paging not Implemented for retrieveMultiple

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.

Angular app and IE

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?

SOAP retrieveMultiple methode

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.

Allow passing empty queries properly

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

Uncaught SyntaxError: Unexpected number in JSON at position 1

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.

require("https")

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

Retrieve Metadata

Is it possible to retrieve Metadata using the webapi, like EntityDefinitions, etc?

Require statement

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");

Unable to execute batch update records with batchOperation

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: (

body.push(`POST ${apiConfig.url}/${changeSets[i].queryString} HTTP/1.1`);

Is there a way to override this value or could it be that I have overlooked a configuration?

I have doubts about `getRequest` method

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");
}

The automated release is failing 🚨

🚨 The automated release from the 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.


No npm token specified.

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 πŸ“¦πŸš€

Module not found: Error:

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'

The message header '--batch_BATCH123' is invalid

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);
    });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.