Now we have a
basic understanding of web resources, let's create a web resource of the type JavaScript that will have the function name Hello
, and attach it to a Microsoft CRM 2011 entity.
Use the following steps to create a "Hello World" JavaScript web resource:
HelloWorld.js
HelloWorld
Script (Jscript)
English
function Hello() { alert('Welcome to Web Resource'), }
Now that our web resource is ready, we can attach this web resource to the entity form and associate our Hello
function with the form entity event. Let's call this function in the OnLoad
event of the account entity form.
First we need to add the account entity to our solution. Once the account entity is added, use the following steps to attach our web resource with the entity form:
OnLoad
, as seen in the following screenshot:Now, when we try creating a new account record, we should get a welcome pop up as shown in the following screenshot:
We can access Microsoft CRM 2011 data in JavaScript and Silverlight web resources. Microsoft CRM 2011 provides the following two endpoints for this:
REST
stands for Representational State Transfer. It works in a similar way to the Internet; for example, we can access
resources on the Internet by their unique URIs, and in a similar way, in REST we can access every resource by its unique URI. We can write both synchronous and asynchronous requests using REST endpoints. Microsoft CRM 2011 provides a Windows Communication Foundation (WCF) data services framework to provide OData endpoints, which is a REST-based data service and is called Organization Data Service. In Microsoft CRM 2011, we can access Organization Data Service by using the URI [Your Organization Root URL]/xrmservices/2011/organizationdata.svc
.
We can only write
, create
, update
, retrieve
, delete
, associate
, and disassociate
requests using REST endpoints. You can refer to http://msdn.microsoft.com/en-us/library/gg309549.aspxfor sample code to use REST endpoints in JavaScript and jQuery web resources.
Microsoft CRM 2011 also provides SOAP endpoints, which provide access to all the methods on the Organization service. It does not support strong type; only the types defined in WSDL will be returned. You can refer to http://msdn.microsoft.com/en-us/library/gg594434.aspx to use SOAP endpoints in JavaScript.
In both endpoints, the user is authenticated by the Microsoft CRM 2011 application itself, but we cannot use these endpoints outside of the Microsoft CRM 2011 application context.
3.145.179.85