XrmServiceToolkit.Rest.Retrieve

May 15, 2012 at 9:07 PM

I am fairly new to CRM Coding and this toolkit. I am trying to use the   XrmServiceToolkit.Rest.Retrieve to pull detailed info on a account. if I plug a accountid guid into account id in the third line below.  I am able to pull all the fields back that I want in the result function and then assign variables to them. I am trying to find out a way to filter by another custom field on the account. like a location number. is this possible and if so how would this code look

Thanks

 

function test1 () {

            XrmServiceToolkit.Rest.Retrieve(
                AccountId,
                "AccountSet",
                null, null,
                function (result) {
                   
                    var Id = result.AccountId);
                },
                function (error) {
                    alert("failed");
                },
                false
            );
        }

May 17, 2012 at 8:56 AM

You'll have to use `XrmServiceToolkit.Rest.RetrieveMultiple` and write a little of raw oData.

XrmServiceToolkit.Rest.RetrieveMultiple(
    'ActivityPartySet', // entity name + 'Set'
    '$filter=LocationNumber eq' Xrm.Page.getAttribute('locationNumber').getValue(), // Some raw oData goodness, assuming field is a string. Hopefully, there will be an API for filters in further versions.
    batchSuccessCallback, // retrieved data is paged (50 records a batch). this will be called after every batch. Process retrieved data here or it will be overwritten by next batch.
    errorCallback,
    OnComplete, // this, finally, will be called after all pages are retrieved
    false // async or not?
    );

Coordinator
Jul 25, 2012 at 10:56 AM

Hey There.

Have a look at the XrmServiceToolkit.Soap.QueryByAttribute funciton. It might be the eaiser one to use.

Jaimie