Addition of byExpandRetrieve function?

Developer
Oct 31, 2014 at 2:37 PM
Hi Thuld,

What do you think of adding in a byExpandRetrieve function?
    function byExpandRetrieve( entityName, id, columns, expand, opt_asyn ) {

        // default is 'true'
        var asyn = ( opt_asyn === undefined ) ? true : opt_asyn,
            setName = entityName + 'Set',
            query = getODataPath() + "/" + setName + "(guid'" + id + "')" + "?$select=" + columns.join( ',' ) + '&$expand=' + expand;

        // returns a promise instance
        return doRequest( { url: query }, asyn );
    }
Regards

Matt
Coordinator
Nov 2, 2014 at 6:52 PM
Edited Nov 3, 2014 at 1:44 PM
Hi Matt,

The lib. provides the byExpandQuery function. Does this already provide the required functionality, or do I miss an point? As fare as I can see the only difference is the filter parameter.

Daniel
Developer
Nov 3, 2014 at 9:06 AM
Sorry I didn't realise I had accidently created three threads!

I'm currently trying to integrate the CrmRestKit with the CRM REST Builder tool (https://crmrestbuilder.codeplex.com/) and need to do an expand on a retrieve.

Matt
Coordinator
Nov 3, 2014 at 11:37 AM
Edited Nov 4, 2014 at 8:24 PM
Hi Matt,

but the mentionded function (ByExpandQuery) does provided the functionality to retrieve an expand query:
function byExpandQuery( entityName, columns, expand, filter, opt_asyn ) {

        // default is 'true'
        var asyn = ( opt_asyn === undefined ) ? true : opt_asyn;

        // in case filter is empty 
        filter = ( filter ) ? "&$filter=" + encodeURIComponent( filter ) : '';

        // create defered object
        var setName = entityName + 'Set',
            query = getODataPath() + "/" + setName + "?$select=" + columns.join( ',' ) + '&$expand=' + expand + filter;

        return doRequest( { url: query }, asyn );
    }
I am right now on holidays so maybe I do not get the point but do you need any futher functionallity?

Daniel
Developer
Nov 3, 2014 at 2:33 PM
Yes I do understand. I however want to be able to retrieve a particular record in CRM by using the following OData URL syntax
setName + "(guid'" + id + "')" 
This will allow the CRM REST Builder to create a Retrieve Single with expand capability and not specify a filter.

This is not a urgent request but thought it would be great to have this library integrated in the tool as it's quick and easy to generate the code required to call REST libraries.

Let me know what you think.

Thanks

Matt
Coordinator
Nov 4, 2014 at 12:17 PM
Hi Matt

ok now I got it :)

The only thinks is the name of this new method. I would suggest "RetrieveExpand" instead of "byExpandRetrieve".

Your are setup as developer of this project so you should be able (in terms of the permissions) to update the source-code and check the new code in. I am not 100% sure if you could create a new package but we could do that together. Please include some tests that verify the function works as expected.

Regards,

Daniel
Developer
Nov 5, 2014 at 8:28 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Developer
Nov 5, 2014 at 10:55 PM
Hi Daniel,

Great, I've set it up on my environment. Was wondering what test file do I need to update?

Regards

Matt
Coordinator
Nov 6, 2014 at 7:51 AM
Hi Matt,

in the "unittesting" folder is the "qunit" folder. There you find the "Test.CrmRestKit,htm" file. These are the intergation test for the 2.x Version of the CrmRestKit.

To run the test you Need to deploy this file as web-resource (including the dependencies).

Regrads,

Daniel