/// /// For a full list of all supported methods, see "\Test.CrmRestKit.htm" ///
/// /// Retrieve the product-price-level records by product id /// var productid = '{AEF9BD9A-BB6A-E011-9460-1CC1DE085868}', entity = 'ProductPriceLevel', cols = ['PriceLevelId'], filter = "ProductId/Id eq guid'" + productid + "'"; CrmRestKit .ByQueryAll(entity, cols , filter, true) .fail(function (xhr, status, ethrow) { alert('Error: ' + status + ': ' + xhr.statusText + '.'); }) .done(function (data, status, xhr) { alert("Ok"); } ); /// /// Retrieve -asyn- /// CrmRestKit.Retrieve( 'Account', this.accountId, ['Name'] ).fail( window.globalFail ).done( function ( data ) { // Assert equals( data.d.Name, 'Test', 'Retrieve passed' ); // continue witht the other tests start(); } ); /// /// Retrieve -sync- /// CrmRestKit.Retrieve( 'Account', this.accountId, ['Name'], false ) .fail( globalFail ) .done( function ( data ) { // Assert equals( data.d.Name, 'Test', 'Retrieve passed' ); } ); /// /// ByQuery -asyn- /// CrmRestKit.ByQuery( 'Account', ['AccountId'], "Telephone3 eq '" + this.phone + "'" ) .fail( function () { // Assert ok( false, 'Error occured' ); start(); } ) .done( function ( data, status, xhr ) { // Assert equals( data.d.results.length, 2, 'Expected two, found : ' + data.d.results.length ); // continue with the other tests start(); } ); /// /// ByQuery -sync- /// CrmRestKit.ByQuery( 'Account', ['AccountId'], "Telephone3 eq '" + this.phone + "'", false ) .fail( globalFail ) .done( function ( data, status, xhr ) { // Assert equals( data.d.results.length, 2, 'Expected two' ); } ); /// /// LazyLoading /// var counter = 0; CrmRestKit.ByQuery( 'Account', ['AccountId'], "Name eq 'Test'", false ) .done( function fnSuccess( data ) { counter++; if ( data.d.__next ) { CrmRestKit.ByQueryUrl( data.d.__next, false ).done( fnSuccess ); } } ); /// /// Create -sync- /// var account = { 'Address1_City': 'Hessisch Oldendorf', 'Name': 'Test' }; CrmRestKit.Create( 'Account', account, false ) .fail( globalFail ) .done( function ( data, status, xhr ) { ok(( data.d.AccountId !== undefined ), 'Create passed' ); } ); /// /// Update -sync- /// CrmRestKit.Update( 'Account', context.accountId, { Name: 'afterUpdate' }, false ) .fail( globalFail ) .done( function ( data, status, xhr ) { CrmRestKit.Retrieve( 'Account', context.accountId, ['Name'], false ).then( function ( data ) { ok( data.d.Name == 'afterUpdate', 'update passed' ); } ); } ); /// /// Delete -sync- /// CrmRestKit.Delete( 'Account', this.accountId );