Giter VIP home page Giter VIP logo

dynamicsnode's Introduction

Windows Build Coveralls npm npm downloads dependencies ghit.me Package Quality

Project description

DynamicsNode is a library built on node.js that allows you to quickly create scripts to interact with Microsoft Dynamics CRM using JavaScript.

The main goal of DynamicsNode is to make you very productive when it comes to automate small tasks in Dynamics CRM. Just create a .js file, add a few lines and execute it.

No more .net console applications with all the boilerplate code just for creating one record. Go productive!

Github project: https://github.com/crisfervil/DynamicsNode

Review the changelog to see the latest changes.

If you want to receive notifications about new releases, you can star this project in GitHub and use https://sibbell.com

How to use it

Create a new directory to store your scripts and cd into it

$ mkdir MyScripts && cd MyScripts

Install DynamicsNode

$  npm install dynamicsnode

Writing code

Create a new js file named myscript.js and start adding code

var dn = require("dynamicsnode");

// update this with your CRM url and credentials if needed
var crm = new dn.CRMClient("Url=http://crm.contoso.com/xrmContoso"); 

// retrieve current user information
var who = crm.whoAmI();
var myUserInfo = crm.retrieve("systemuser",who.UserId);
console.log(myUserInfo.fullname); // prints your user name

// retrieve a user named John Doe
var anotherUser = crm.retrieve("systemuser",{fullname:"John Doe"});
console.log(anotherUser); // prints all the attributes of the user

Save the file and run the script.

In order to run the script use node

$ node myscript

Further information: API

How to compile and test the code: Compile and Testing

Use it as a command line tool: Commands and Repl

Requirements

Requires Node.js

This tool is based on Edge and requires .NET Framework 4.5 to be installed.

It has been tested in Windows environments only, but could potentially work in Linux too using Mono.

Supported CRM versions

Tested on CRM 2011, 2013 and CRM Online so far.

Volunteers to run the integration tests on other versions are more than welcome :)

Backlog

(Ordered by priority)

  • Get 85%+ code coverage
  • Refactor to minimize .net code
  • Add paging support in queries
  • Add async support
  • Improve Exception handling and Show errors thrown in the CRM side
  • Add support for .net core
  • Make it work in Mono and Linux
  • Add functions to work with solutions
  • Add an Assert object to allow create integration tests
  • Add examples page
  • Add a commands to work with connections
  • Add more commands to repl mode
  • Add support for missing operators in condition objects
  • Add d.ts file to Typings repository
  • Add functions to create performance tests
  • Add functions to allow Continuos Integration tools
  • Add extensibility
  • Add integration tests for activities
  • Improve documentation
  • Add DataTable functions
  • Improve testeability and integration tests
  • Add import/export commands
  • Add test coverage reports
  • Upload npm package

dynamicsnode's People

Contributors

crisfervil avatar gabrielgab avatar nhance 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamicsnode's Issues

Pagination contribution

Hi, first of all I would like to start contributing to this Project, I saw in the backlog that you are working in some things, could you update that so I dont work in something that you'r working on?

My first contribution would be add pagination on retrieve requests, in my client they have some big entities, and they're not returning everything... but adding pagination on retrievemultiple requests have some undesired impacts(like requests taking too long to do something simple) so I thought in adding a new method retrieveMultiplePagination so you can explicitly say when you need pagination.... what you guys think ? Let me know your opinion so I can start doing it.

Cannot find module 'DynamicsNode'

I'm on ubuntu usung node 4.2.6 and getting following error

Error: Cannot find module 'DynamicsNode'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/jasenko/Desktop/MyScripts/script.js:1:72)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)

Could it be because of node version or linux or something third?

Some functions missing

Hi Cris , I see that in CRMBridge.cs are implemented some functions like associate and dissociate , but they are not exposed in the object model. Others like Create , Fetch , Delete , Update , are all working ok in my tests - on premise and online CRM organizations -
So i think that something is missing in CRMClient.js file, in order to expose all the functions located in CRMBridge.js .

By the way - I really appreciate this library - long waiting for this kind of contribution - thanks
Gabriel

NPM install fails

NPM install is failing because the package.json refers to bin/commands.js which is not part of the repository.

Error message:

npm ERR! Windows_NT 10.0.14965
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\nick\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v7.2.0
npm ERR! npm  v4.0.3
npm ERR! path C:\Users\nick\Source\Repos\foobar\node_modules\dynamicsnode\bin\commands.js
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\nick\Source\Repos\foobar\node_modules\dynamicsnode\bin\commands.js'
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\nick\Source\Repos\foobar\node_modules\dynamicsnode\bin\commands.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\nick\Source\Repos\foobar\npm-debug.log

Suggested resolution ideas:

  • Allow the compiled files to be a part of the repository?
  • Explore how other node modules built with typescript are shipped.. is this standard?
  • Change the bin to use the typescript file instead?

I will explore these options, but it may be difficult to test.

exporting/importing entities

hi @crisfervil , I don't understand how I can get access to those funcionalities .

I found this quote:
$ di export systemuser users.xml

But , is this a command of nodes module ?

need some help , thanks !

Error trying to connect to Server: Metadata contains a reference that cannot be resolved

I tried your module on Linux Ubuntu 14.04 with latest Mono 4.2 calling external on premise dynamics crm 2015. When checking, if XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1 is available via url, it is accessible. I get following error, when trying to access it.

Error: Error trying to connect to Server: Metadata contains a reference that cannot be resolved : http://crmsrv.example.com:5555/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1
System.InvalidOperationException: Metadata contains a reference that cannot be resolved : http://crmsrv.example.com:5555/XRMServices/2011/Organization.svc?wsdl&sdkversion=7.1 ---> System.ServiceModel.EndpointNotFoundException: System error. ---> System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) <0x4025ab40 + 0x00117> in :0
at System.ServiceModel.Channels.HttpRequestChannel+c__AnonStorey1.<>m__0 (IAsyncResult r) <0x4025a730 + 0x000ae> in :0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) System.ServiceModel.Description.IMetadataExchange:Get (System.ServiceModel.Channels.Message)
at System.ServiceModel.Description.MetadataExchangeClient.GetMetadataInternal (System.ServiceModel.EndpointAddress address, MetadataExchangeClientMode mode) <0x401d4290 + 0x0024e> in :0
--- End of inner exception stack trace ---
at System.ServiceModel.Description.MetadataExchangeClient.GetMetadataInternal (System.ServiceModel.EndpointAddress address, MetadataExchangeClientMode mode) <0x401d4290 + 0x002f7> in :0
at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata (System.Uri address, MetadataExchangeClientMode mode) <0x401d3df0 + 0x0005b> in :0
at Microsoft.Xrm.Sdk.Client.ServiceMetadataUtility.RetrieveServiceEndpointMetadata (System.Type contractType, System.Uri serviceUri, Boolean checkForSecondary) <0x401cea20 + 0x00297> in :0
at Error (native)
at :1:55
at new CRMClient (/home/deploy/Projects/crm-rest/dynamicsintegration/node_modules/dynamicsintegration/CRM/CRMClient.js:34:26)
at Object. (/home/deploy/Projects/crm-rest/dynamicsintegration/test.js:3:11)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)

Integration Test

@crisfervil , I have discovered the integration Test files ๐Ÿ‘ so I followed the steps and run it .
It's all ok for the new functions ( associate and dissociate ) , but arrives some other error for fetching .
target : CRM 2011 - on premise -

Image attach , i will see it toninght
integrationtest

Regards

Creating a case with an associated account.

Hi,
Can you please tell me how I can create a case with an existing account. Below is the code I tried:

var parent = new Array();
parent[0] = new Object();
parent[0].id = "70AB9DC7-0B21-E611-80DD-5065F38B6122";
parent[0].name = "Account name";
parent[0].entityType = "account";

var createCase = crm.create("incident", {
title: "caseTitle",
customerid: parent
});

Below is the exception I got via the console.

Error: The formatter threw an exception while trying to deserialize the message
: There was an error while trying to deserialize parameter http://schemas.micros
oft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'Erro
r in line 1 position 10215. Element 'http://schemas.microsoft.com/2003/10/Serial
ization/Arrays:anyType' contains data from a type that maps to the name 'System.
Dynamic:ExpandoObject'. The deserializer has no knowledge of any type that maps
to this name. Consider changing the implementation of the ResolveName method on
your DataContractResolver to return a non-null value for name 'ExpandoObject' an
d namespace 'System.Dynamic'.'.

Please let me know what I am missing here.

Thanks

update a date field to null

Hi @crisfervil , I have this issue , trying to set to null a date , I get this error .

image

This is may code :

var account = {} ;
account.accountid = '7D0C0490-9934-E611-80C3-005056AC0018' ;
account.name = "now3" ;
account.new_deliverdate = null ;
crm.update("account", account );

What am I doing wrong ,
Thanks in advance .

Needs a License

Please add a LICENSE.MD file to this project. I can't find any licensing information and therefore I can't bring into a project, since I don't know the terms of use.

GitHub makes this very easy (http://stackoverflow.com/a/31666878/394978). I usually use the MIT License but the copyright owner gets to choose.

Add asynchronous support

Hi @crisfervil, great tool!

I'm using your package in an electron desktop app and so far it works great.
One thing I'm missing is to have callbacks to respond the events.
Like when I do a retrieveMultiple() call, I want to show an animation, and when the data is fetched I want to stop the animation. Right it just happens when it happens.

Do you think thats possible somehow?
Thanks!

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.