Node.js Hello World on Windows

In this example, we will create a Hello World application for Node.js. Let’s start with a simple example. I have installed Node.js on Windows and have a Node directory in C:\ drive. In command prompt, cd to this directory. In that directory is a JavaScript file that writes out a console log “Hello World”: To run the file, enter: node HelloWorld.js Hello World is returned by Node. Now create a new … Continue reading Node.js Hello World on Windows

D3 Hello World

To create a D3 “Hello World”, do the following. Go to the website and find the latest D3 version: Copy the link to the latest release: <script src=””></script> Create an HTML page and add the following code, with the link above: <!DOCTYPE html> <meta charset=”utf-8″> <body> <script src=””></script> <script>“body”).append(“span”) .text(“Hello world”); </script> Run the page:  

Dynamics 365 $ is not defined

In your JavaScript code, you may receive this error when running jQuery code: $ is not defined To resolve this, add the following code to JavaScript before the jQuery call is made: if (typeof($) === ‘undefined’) { $ = parent.$; jQuery = parent.jQuery; }

JavaScript console.log Hello World

console.log allows for developers to write log events to certain web browsers. Here we will do a Hello World example using Chrome. First, create a new html document, and add the code: Open the document in Chrome and select F12 to open the developer tools. Go to the Console tab. You will now see the output: This logging can be useful in troubleshooting code. You can additionally write commands directly … Continue reading JavaScript console.log Hello World

Classes in JavaScript

There are different ways to define classes in JavaScript. Let’s look at some examples. Let’s say you want to define a class for a Customer. The customer contains attributes such as: First Name Last Name Email Phone Number The Customer class also contains methods such as GetCustomer to get the customer information. Now, to create a customer class, we can do the following. Note we are creating a function to … Continue reading Classes in JavaScript

Dynamics CRM JavaScript OnSave and OnLoad

In Dynamics CRM, you have the ability to hook onto the OnLoad and OnSave events of an entity. We will go through a simple example. Open the entity in Customizations. Let’s do this with Accounts. Go to Form Properties: Under UI Events, you will see the two options for OnLoad and OnSave. Let’s start with adding a new JavaScript library. Select Add: And then New: Enter a name and select JScript: … Continue reading Dynamics CRM JavaScript OnSave and OnLoad

Node Server Upgrade on Windows

Here we will go throgh the steps to upgrade your Node server. First, open PowerShell as Administrator. We will check the version of the server currently installed, with the command: node -v Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force Then run: npm install -g npm-windows-upgrade Next, run: npm-windows-upgrade Select a version: You will see: And once complete:  

Install Node on Windows

To install Node on Windows, first go to the Node website and select the version to download. We will install Windows 64 bit: This downloads the MSI file. Open the file: Click Next: Click Next: Click Next: Select all the required components, including NPM Package Manager. Click Next: Click Next: Click Finish: With NPM installed, you have access to thousands of packages. You can read more about NPM at … Continue reading Install Node on Windows

Function Overloading in JavaScript

Function Overloading is the ability to define two or more functions with the same name that have a different signature, i.e. a number and/or different types of parameters/arguments. For example: function DoSomething(a) function DoSomething(a,b) function DoSomething(a,b,c) In JavaScript, there is no function overloading. There is however behavior regarding sending different parameters, and there is a pattern we can use to handle function overloading. First, consider the case above. If we … Continue reading Function Overloading in JavaScript

JavaScript Promises

JavaScript promises are a way in JavaScript to write asynchronous code in a synchronous way. They are asynchronous callbacks, but in terms of error handling are much more readable. Here we will go through an example of how to use promises. We define a promise as below, with 2 parameters, resolve and reject: new Promise((resolve, reject) If the promise is resolved, we can perform an action, and if it is rejected, … Continue reading JavaScript Promises