Development, Howto

Microsoft Dynamics 365 v9.0: Usage of new OOB WebApi functions – Part 1

It was anounced earlier that wrapper for usage of WebApi will be available as a part of v9.0 release. Now v9.0 is released so it became possible to check what can it do and what we can do with it.

Here is the list of methods available under Xrm.WebApi:

  • createRecord
  • updateRecord
  • deleteRecord
  • retrieveRecord
  • retrieveMultipleRecords
  • execute
  • executeMultiple

All methods return Promise object.

Examples:

createRecord method accepts 2 parameters – entity schema name and data of object to create:

updateRecord method accepts 3 parameters – entity schema name, id of record and data of object to update:

deleteRecord method accepts 2 parameters – entity schema name and id of record to delete:

retrieveRecord method accepts 3 parameters – entity schema name, id of record and optional “options” parameter that includes $select, $expand and other options you want to use in retrieve statement.

*Note you don’t need to add anything to get Formatted Values of lookups or optionsets – it is done by default:

retrieveMultipleRecords method accepts 3 parameters – entity schema name, optional “options” parameter (with query you want to use to retrieve data) and optional “maxPageSize” parameter that defines number of records per page returned with response (you can check detailed explanation here):

I will describe execute and executeMultiple methods in following posts:

Microsoft Dynamics 365 v9.0: Usage of new OOB WebApi functions – Part 2

Microsoft Dynamics 365 v9.0: Usage of new OOB WebApi functions – Part 3

5 Comments on “Microsoft Dynamics 365 v9.0: Usage of new OOB WebApi functions – Part 1

  1. Xrm.WebApi.retrieveRecord(…”$select=name,_ownerid_value”)
    Xrm.WebApi.retrieveMultipleRecords(…”$select=name,_ownerid_value&$filter=name eq ‘test'”..)
    There is a awful OData style… If I write something similar I’ll change params to individual parts:
    – [‘name’, ‘ownerid’]
    – [‘name’, ‘ownerid’], “and”, [‘name’, ‘eq’, ‘test’]

    1. I agree that style is not the best one but at the end you get plain url with additional payload based on the type of operation.

Leave a Reply

Your email address will not be published. Required fields are marked *