New Style of Writing Javascript

var Maths = {

    addNumbers: function(one, two) {
        return one + two;
    },

    subNumbers: function(one, two) {
        return one - two;
    },

    mulNumbers: function(one, two) {
        return one * two;
    },

    divNumbers: function(one, two) {
        if (two != 0)
            return one / two;
        else
            return "Division failed. Denominator cannot be Zero";
    }

}

function mathOperations() {
    alert(
        "Addition of 10 and 20 is " + Maths.addNumbers(10, 20) + "\n\n" +
        "Substraction of 10 and 20 is " + Maths.subNumbers(10, 20) + "\n\n" +
        "Multiplication of 10 and 20 is " + Maths.mulNumbers(10, 20) + "\n\n" +
        "Division of 10 and 20 is " + Maths.divNumbers(10, 20)
    );
}

Output:
New Style Javascript

Advertisement

Calculate difference between two dates using Javascript

Difference between two dates

Input String: calculateDays(“01-01-2014″,”12-12-2014”)

Date Format: MM-DD-YYYY

function calculateDays(datetime1, datetime2) {
var oneDay = 1000 * 60 * 60 * 24;        // The number of milliseconds in a day
//Convert the datetime1 and datetime2 to Date object and get Time in milliseconds

var dt1 = new Date(datetime1).getTime();
var dt2 = new Date(datetime2).getTime();

// Calculate the difference in milliseconds
var diff = Math.abs(dt1- dt2); // Difference of Days

return Math.round(diff / oneDay);
}

Auto Number generation using Real Time Workflow in MS CRM 2013

Auto Number generation using Real Time Workflow in MS CRM 2013

Hi All,

I am going to show you the example of Real Time Workflow for Auto Number generation.Follow the below steps to create Auto Number for Contact entity,

Step 1: Create a Custom Entity “Counter” with the following Fields

Counter Value: Whole Number (Range as required)

Step 2: Create One Record in Counter entity as follows,

Counter Entity

Step 3: Create N:1 relationship between Contact to Counter entity as follows,

Contact to Counter realtionship

Step 4: Create “Contact ID” field in Contact entity as follows,

Contact Id field creation in Contact Entity

Step 5: Place “Contact ID” and “Counter_Contact” fields on the Contact entity form and hide them,

Contact Form

Step 6: Create a Real time workflow as follows,

Workflow Wizard
Workflow Creation

Step 7: Create a step to Update “Counter-Contact” record in Contact entity as follows,

Workflow Step 1
Workflow Step 1.1

Step 8: Update Counter Value from Counter entity as follows,

Workflow Step 2
Workflow Step 2.1

Step 9: Update Counter Value by 1 in Counter entity

Workflow Step 3
Workflow Step 3.1

Step 10: Activate the Process and Create Contact Record

Auto Number Generation

Please provide your valuable comments.