Ramblings about MS Dynamics CRM 2011 and coding basics.

Tuesday, October 31, 2006

JavaScript Math Functions

Since CRM 3.0 uses JS natively in the OnLoad and OnSave events, I have decided to post several key math functions in JS.

Also remember to use parentheses around the condition when writing an if statement, such as:
if (condition)
{
action;
}

//General math calculations
+ //Addition
- //Subtraction
/ //Division
* //Multiplication
% //Modulus (remainder after division)
++ //Increment by 1
-- //Decrement by 1

//Higher math calculations
MATH.ABS(X) //Absolute value of X
MATH.ACOS(X) //Arc Cosine of X
MATH.ASIN(X) //Arc Sine of X
MATH.ATAN(X) //Arc Tangent of X
MATH.ATAN2(X,Y) //Arc Tangent of X/Y
MATH.CEIL(X) //Integer closest to X and not less than X
MATH.COS(X) //Cosine of X
MATH.E //Euler's constant
MATH.EXP(X) //Exponent of X
MATH.FLOOR(X) //Integer closest to X and not greater than X
MATH.FLOOR(MATH.RANDOM()*10) //Returns random value between 0 and 9
MATH.LN10 //Natural Log of 10
MATH.LN2 //Natural Log of 2
MATH.LOG(X) //Log of X base E
MATH.LOG10E //Base-10 Log of E
MATH.LOG2E //Base-2 Log of E
MATH.MAX(X,Y) //Returns the maximum value of X or Y
MATH.MIN(X,Y) //Returns the minimum value of X or Y
MATH.PI //Pi
MATH.POW(X,Y) //X to the power of Y
MATH.RANDOM() //Returns random value between 0 and 1
MATH.ROUND(2.8) //This would equal 3
MATH.SIN(X) //Sine of X
MATH.SQRT(1_2) //Square Root of 1/2
MATH.SQRT(2) //Square Root of 2
MATH.TAN(X) //Tangent of X

//Operators
X=Y //X equals Y
X+=Y //X equals X plus Y
X-=Y //X equals X minus Y
X*=Y //X equals X multiplied by Y
X/=Y //X equals X divided by Y
X%=Y //X equals X modulus by Y
== //Equivalent
=== //Exact equivalent
!= //Not equal to
> //Greater than
< //Less than
>= //Greater than or equal to
<= //Less than or equal to
&& //And
//Or
! //Not

There are a lot of other powerful functions or more complex ways of putting these above listed functions together, but this should get you started.

Labels: , , , , ,

Sunday, October 29, 2006

Introduction to crm blogging


Hello,

I am a consultant specializing in MS CRM 3.0. I currently work and reside in Austin, TX. I am mostly doing application customizations in CRM and some in VS.net 2005. I have decided to start a blog to hopefully spread some of my wisdom, just as I have gained some from other helpful crm blogs. I hope you enjoy my blog and find it useful (after I start posting blogs...)

-Mark N