JavaScript Serial Number Generator

To generate a random serial number, based on a given mask, you can use the following code: // Serial Number Generator // Generates a random number in a certain interval function GenerateRandomNumber(min,max) { return Math.floor(Math.random() * (max – min + 1)) + min; } // Generates a random alphanumberic character function GenerateRandomChar() { var chars… Continue reading JavaScript Serial Number Generator

Useful JavaScript functions & methods for CRM 2011 – CWS.CRM.Utils.js Library

Starting with this great article, I’ve created a JavaScript Library with several useful functions & methods for CRM 2011, such as: – CRM Service class to Create, Update, Retrieve, RetrieveMultiple, Delete records in CRM (SOAP based); – Custom Runtime Advanced Filtered Lookup support; – Set Lookup Value programmatically support – Guid Generator – CRM Form Buttons… Continue reading Useful JavaScript functions & methods for CRM 2011 – CWS.CRM.Utils.js Library

Generate a new Guid in JavaScript

As easy as that 🙂 // Generate new Guid function Hexa4() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); } function GenerateGuid() { return (Hexa4()+Hexa4()+”-“+Hexa4()+”-“+Hexa4()+”-“+Hexa4()+”-“+ Hexa4()+Hexa4()+Hexa4()).toUpperCase(); } // USE var guid = GenerateGuid(); alert(guid);

Creating records in CRM 2011 using JavaScript

Using the CRM Web Service, you can create new entity records, just using JavaScript. The following code demonstrates this: // Make Struct function MakeStruct(names) { var names = names.split(‘ ‘); var count = names.length; function constructor() { for (var i = 0; i < count; i++) { this[names[i]] = arguments[i]; } } return constructor; }… Continue reading Creating records in CRM 2011 using JavaScript

JavaScript structures

Here’s a brief example of how to create structures in JavaScript. We’ll use this function a lot from now on in our code. // Make Structfunction MakeStruct(names) { var names = names.split(‘ ‘); var count = names.length; function constructor() { for (var i = 0; i < count; i++) { this[names[i]] = arguments[i]; } }… Continue reading JavaScript structures

Published
Categorized as JavaScript

Large Integer division remainder

Recently, I had to obtain the remainder of a (seriously) large integer division (32 digits long divided by another shorter integer; base 10) and found that JavaScript reliably supports operations only on 15-digit long integers. Thus, this what I came up with: // Gets the remainder from the division operation for LARGE numbers// Support: positive… Continue reading Large Integer division remainder

Published
Categorized as JavaScript

Random Custom Serial Number Generator

A brief example on how to generate random serial numbers with JavaScript. Enjoy! // Symbols Array (A-Z, 0-9) var Symbols = new Array(); // Gets the ascii code for a certain character function GetAsciiBySymbol(letter) { var code = letter.charCodeAt(0); return code; } // Populates a certain array with the A-Z, 0-9 symbols function PopulateArray(array) {… Continue reading Random Custom Serial Number Generator

Published
Categorized as JavaScript

Replace Chars in String – prototype example

An elegant way to replace certain chars from a string with new ones: // Custom method for replacing certain chars from a string with new onesfunction ReplaceChars(oldValue,newValue) { var newText = this.split(oldValue); newText = newText.join(newValue); return newText;} // Attach the custom method to string objectString.prototype.Replace = ReplaceChars; // Usagevar myString = “Hello World!”;alert(myString.Replace(“o”,”0″)); // will… Continue reading Replace Chars in String – prototype example

Published
Categorized as JavaScript