Dynamic CRM 2015 Learning Note (3) OData Query method and GUID value comparison

Source: Internet
Author: User

This article compares the differences between the two query strings in the same OData query method, and also describes how to compare the values of the GUIDs returned by different methods.

With the same OData query method, if the string of the incoming query is different, the format of the returned result is completely different.

1. OData Query method:

OData Query
odataretrieve:function (odatastring) { var retrievereq = new XMLHttpRequest (); Retrievereq.open ("GET", encodeURI (XRM.PAGE.CONTEXT.GETCLIENTURL () + "/xrmservices/2011/ organizationdata.svc/" + odatastring), false); Retrievereq.setrequestheader ("Accept", "Application/json"); Retrievereq.setrequestheader ("Content-type", "Application/json;charset=utf-8"); retrievereq.send (); return json.parse (retrievereq.responsetext). D; }

2. The first method of querying

The query parameters are as follows:

var buvalue = Xrm.Page.getAttribute (' Tm_businessunit '). GetValue () [0].id; var odatastring = ' Businessunitset? $select =tm_systemuser_businessunit_nltautosales/parentsystemuserid & $expand =tm_systemuser_businessunit_nltautosales& $filter =businessunitid eq guid\ ' + buvalue + ' \ ";

The filter is used here.

You can see the results returned in the following format:

We must use Retrievedopp. Results[0]. Tm_systemuser_businessunit_nltautosales. Parentsystemuserid to get results

3. Second method of querying

The query parameters are as follows:

var buvalue = Xrm.Page.getAttribute (' Tm_businessunit '). GetValue () [0].id; var odatastring = ' Businessunitset (guid\ ' + buvalue + ' \ ')? $select =tm_systemuser_businessunit_ nltautosales/parentsystemuserid& $expand =tm_systemuser_businessunit_nltautosales ';

There is no use of the filter, the GUID used directly.

The results returned are as follows:

We can use retrievedopp.tm_systemuser_businessunit_nltautosales. Parentsystemuserid to get results

4. Guid comparison

If GUIDs are GUIDs that are taken from the interface using the same method, such as GetValue (), we can compare their values directly with [0].id], if the GUID returned by OData is compared with the GUID of GetValue () on the interface. You will find that the GUID value returned with the above OData query method is not {}, and is lowercase, whereas the GUID used with GetValue () on the interface is not only used for {}, but also uppercase. At this time if directly with = = To compare, certainly is not. A general comparison method is described below.

Determine that two GUIDs are the same
    Guidsisequal:function (GUID1, Guid2) {
        false;
        if NULL null) {
            "" ""). toLowerCase ();
        }
        return isequal;
    }

Dynamic CRM 2015 Learning Notes series Rollup

Dynamic CRM 2013 Learning Notes Series summary (46 articles)

Dynamic CRM 2015 Learning Note (3) OData Query method and GUID value comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.