by Hosk 

The blog Slow xRM has a really good list of useful Javascript articles for CRM 2011.

To check out the whole list go and read the blog post here.  I have copied a sample of some of the articles which I thought were useful and yes of course I put the links to my blog in here.

I would say the most useful CRM 2011 Javascript links on my blog our

CRM 2011 – Javascript Xrm.Page Basics

CRM 2011 – Comparison between CRM 4.0 and CRM2011 script

CRM 2011 – Getting the ServerUrl in Javascript and using Xrm.page

CRM 2011 – Javascript and Subgrids code example

here are some of the links from the Slow xRM article

Date: 01/28/2011 – Source: Biz Forward
Title: Format Date Fields in CRM
Keywords: JavaScript, Date

Date: 06/13/2011 – Source: Power Objects
Title: CRM 2011 Useful JavaScript tidbits
Keywords: JavaScript

Date: 07/24/2011 – Source: MS CRM 2011 Hospital
Title: Auto Refresh of Grids on form while loading MS CRM 2011
Keywords: JavaScript, Form, Grid

Date: 08/07/2011 – Source: MS CRM 2011 Hospital
Title: GetGlobalContext on MS CRM 2011
Keywords: JavaScript, Web Resource

Date: 02/17/2011 – Source: Ben Hosking
Title: How to set up a lookup using Javascript
Keywords: JavaScript, Lookup

Date: 02/24/2011 – Source: Ben Hosking
Title: How to set an attribute label in Javascript
Keywords: JavaScript, Field – Attribute

Date: 05/05/2011 – Source: Ben Hosking
Title: Javascript Date Difference Code
Keywords: JavaScript, Date

b2)Using the CRM 2011 REST Services and Deep Insert to Create Activities

One of the nice features of CRM 2011 is the REST based OrganizationData service. Lately, I have found myself using the REST service more often as it provides a simpler and cleaner method of accessing data from client side JScript. The REST service also provides the ability to do deep inserts of entity and related records. This capability can be leveraged to provide an elegant solution to creating activity records using client side JScript.

3) Tips about JavaScript for Microsoft Dynamics CRM 2011 (3/3)  After list #1 (http://bit.ly/tMsD5t), list #2 (http://bit.ly/vvP6z4), now our last list for this JavaScript article (http://bit.ly/s5zEvP)

4) Create, Update , Delete Record using Javascript 

5) Export JavaScript Utility Updated 

6) Cancelling Onsave Event in MS CRM 2011 using java script
by yes.sudhanshu
Some times we need to do some validations on javascript and that to be done on mostly onsave, so if the validation fails, we do not have to save the form.
In MS CRM 4.0 , it was different as follows
event.returnValue = false;
return false;

In MS CRM 2011, it will in different way as follows
1. need to pass the Context as follows onsave method of form
2. then use the context object inside Save function
function form_Save(executionObj){
executionObj.getEventArgs().preventDefault();}
thats it.

Some tricks –

2) Show all sub grids data in CRM 2011 entity form (More then 4+ Sub grids) 

3) CRM 2011– Some JavaScript Tips

4) Create, Update , Delete Record using Javascript in CRM2011/4.0 

5) Insert Custom button on CRM Form using javascript in CRM 2011

6) Filter lookup values using javascript and fetchXml in CRM 2011  (lookup – option set)

7) Insert Custom button on CRM Form using javascript in CRM 2011 

8) JavaScript: Наследование

9) JavaScript Bookmark Series

    Part 1

    Part 2
    Part 3

10) Execute Server-Side Code from Javascript

11) Save & Publish Button for Forms and WebResources

12) Calculate “days Open” using JScript

Hi, I am trying to write a Jscript that calculates and assigns (to a text field) the “number of days open” for a custom entity. Essentially the calculated field value should equal current date – createdon date. Appreciate any help. We are using CRM 2011-On Premise. Thanks

• Try:

function dateDiff() {
var oToday = new Date();
var currTime = oToday.setHours(0, 0, 0, 0);
var createdOn = Xrm.Page.data.entity.attributes.get(“createdon”).getValue();

difference = currTime – createdOn;
days = Math.floor(difference / (1000 * 60 * 60 * 24));
alert(“Days Open: ” + days);
}

Where “createdon” is somewhere on your form (could be hidden) and the variable ‘days’ is the number of days in integer format from today since created on.

13)  Dynamics CRM 2011 setDefaultView and View Selector

Dynamics CRM 2011 filter lookup using javascript

 I’m not going to write about how to filter look up using JavaScript, it is quite straight forward and can be found in the SDK http://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addCustomView
, Or in many more other blogs.
This post is about setDefaultView and when it is not working.
14) JavaScript + WebResources
17) Hiding Section, Tabs…
18) http://bingsoft.wordpress.com/2011/01/13/default-customer-lookup-to-contact-in-crm-2011/
You can try the following
document.getElementById(“parentcustomerid”).setAttribute(“lookuptypes”, “2”);
document.getElementById(“parentcustomerid”).setAttribute(“lookuptypenames”, “contact:2”);
document.getElementById(“parentcustomerid”).setAttribute(“lookuptypeIcons”, “/_imgs/ico_16_2.gif”);
document.getElementById(“parentcustomerid”).setAttribute(“defaulttype”, “2”);or if using jQuery
$(“#parentcustomerid”).attr(“lookuptypes”, “2”);
$(“#parentcustomerid”).attr(“lookuptypenames”, “contact:2”);
$(“#parentcustomerid”).attr(“lookuptypeIcons”, “/_imgs/ico_16_2.gif”);
$(“#parentcustomerid”).attr(“defaulttype”, “2”);
    FunctionName=”isNANзапись, указывающая на то, что нужно просто загрузить библиотеку; никакая функция вызываться не будет. (Поскольку имя функции должно быть указано обязательно, то используется строковая константа isNAN).