Jscripts snippets for CRM 2011

2011-11-21 | apurvghai | Dynamics CRM SDK | C#


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.
Xrm.Page.context.getServerUrl()
  • Get the string value of a text field
function GetMainPhone() {
   var MainPhone = Xrm.Page.data.entity.attributes
     .get("telephone1").getValue();
}
  • Set the value of a string field
function SetMainPhone() {
  Xrm.Page.data.entity.attributes
     .get("telephone1").setValue();
}
  • Adding value to option set
var optionsetbox = Xrm.Page.getControl("customertypecode")
optionsetbox.text= "Apurv";
optionsetbox.value= "10";
Xrm.Page.ui.controls.get("customertypecode").addOption(optionsetbox,12);
  • Removing a value from option set on fly
Xrm.Page.getControl("customertypecode").removeOption(4);

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

Cheers,
Apurv

Recent Posts
Getting started with Dynamics 365 CRM SDK in C#
Jan 14, 19 | Dynamics CRM SDK
Using Postman with Dynamics 365 Online and OnPremise
Jan 14, 19 | Dynamics CRM SDK
Getting Started with WebAPI
Dec 28, 18 | Dynamics CRM SDK