开发者

How to perform CRUD operations on entities other than Account with Javascript

I've been using this link as a reference on how to perform basic CRUD operations by calling the CRM web service using javascript.

The link开发者_如何学编程 contains a sample that shows how to perform CRUD operations on an account entity. When the XMLHttpRequest object's open function is called in this sample, the second parameter is set to something specific to the account entity.

Here is an example:

createAccountReq.open("POST", ODataPath + "/AccountSet", true);

I see no reference as to what this part of the URL should be set to for other OOB entities or custom entities.

Would someone please point me in the right direction? I assume this information is in the SDK, but I can't seem to find it.


This should help you get a feel for what retrieve operations look like: http://crm2011odatatool.codeplex.com/

Once you get a chance to play around with that, then all you have to do to work with different entities is change the Set name and attribute names. One important thing to note is that you should be using the schema name of entities and attributes, not the logical name. Logical name is always all lowercase, schema names can be all lowercase but often times have uppercase letters. You should easily be able to see that as you play around with the odata tool above.

Lastly, this page is similar to your link but slightly different. Make sure to click the JScript code sections.


The web service follows the standard OData pattern of enumerating all the available resources when you access the root URL. CRM returns an XML list of all possible entities. You may then append any of those entity sets to the URL to query the entity.

For example, accessing https://<CRM Server>/XRMServices/2011/OrganizationData.svc/ will give you something like:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<service xml:base="https://<CRM Server>/XRMServices/2011/OrganizationData.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
  <workspace>
    <atom:title>Default</atom:title>
    <collection href="SdkMessageRequestFieldSet">
      <atom:title>SdkMessageRequestFieldSet</atom:title>
    </collection>
    <collection href="ListMemberSet">
      <atom:title>ListMemberSet</atom:title>
    </collection>
    <collection href="ContactQuotesSet">
      <atom:title>ContactQuotesSet</atom:title>
    </collection>
    ...

Edit: Take a look at the MSDN article titled "Retrieve Entity Metadata using JScript" if you want to retrieve metadata about the entities themselves. It mentions a JavaScript library, that is included in the SDK, which allows you to send a SOAP request to the Organization metadata service to retrieve all the entity details, like LogicalName and DisplayName.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜