Freigeben über


Dynamics 365 - WebAPI Crud Operations (JavaScript)

Hey Guys,

It's been a while since I've posted. I know for sure this is late. I think it would be helpful to see basics items on WebAPI (using JavaScript). The article today talks about the CRUD (Create, update, read and delete) operations using WebAPI endpoints.

You must have working experience in below areas: -

  • Code using Java scripting
  • Dynamics 356 customizations or CRM online 2015,2016, 2016 SP1 Web Resources
  • Visual Studio
  • Conceptual knowledge of ODATA Operations.

I've created HTML web resource in Dynamics 365 and a script Library to add below functions. I will although not explain how to create web resources. The source code is now available on GitHub. The demo covers the following scenario:

  • Searching an existing account, if found it will show an alert with a count of accounts found
    • If not found, then it will ask you if you want to create one.

//Creating Account:

create-webapi-js

//Search or Retrieve Account

retrieve-webapi-js

There are many types of filters which can be used. A list is available at OASIS Open Source Documentation 4.0: https://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_The_$filter_System odata-filters

//Update existing Account: update-webapi-js

Full source of the demo is available on GitHub:

Script Library: https://github.com/apurvgh/Crm_Sdk_Samples/blob/master/new_webapi.lib.js

HTML WebResource: https://github.com/apurvgh/Crm_Sdk_Samples/blob/master/new_webapidemo.html

Thank you for spending time. :)

-Apurv