Jscripts snippets for CRM 2011

I have tried to outline couple of examples that you could use in CRM. These examples are based on Xrm patterns which tells you how you can utilize the resources available in better way. These are newly introduced in CRM 2011. The whole idea is to put together a set of common functions as an library which can be used across the forms. You just need to register them under one common place called web resources and keep attaching them to forms where you need to use these. I will also demonstrate how you can achieve that. Let's get to the list and see what we have in store for today :)

  • Server URL.


  • Get the string value of a text field

function GetMainPhone() {
   var MainPhone = Xrm.Page.data.entity.attributes

  • Set the value of a string field

function SetMainPhone() {

  • Adding value to option set

var optionsetbox = Xrm.Page.getControl("customertypecode")
optionsetbox.text= "Apurv";
optionsetbox.value= "10";

  • Removing a value from option set on fly


I'm still working on more user friendly examples. Please do wait for more. Keep surfing and visiting.