Create and Associate Records in a single operation using Xrm.WebAPI in D365 Customer Engagement

Blog Thumbnail

Introduction
In this blog we will demonstrate how to create and associate records using Xrm.WebApi which provides methods to use Web Api to create and manage records.

Implementation
Step 1: The syntax to create a new entity record is as follows:


Here entityLogicalName(string) and data(object) parameters are required where, "data" is the JSON object defining the attributes and values for the new record.

Step 2: In this example we will create a sample account record along with a primary contact for that account, associate an opportunity to the account and create task and notes for the opportunity all in a single operation. This type of process if called deep insert.


The code for the same is as shown below:


Screenshots:
1. A New Account is created with the name “CRAYONS LTD” and in the primary contact file the primary contact is set with the name Clinton Dmello as set in the code.
Account Creation


2. Also an opportunity is associated to the account as shown below in the associated view.


Opportunity Associated to Account


3. In the opportunity we can see the newly created task in the activities and a note as shown below
Note Created

Task Created
Hope this helped!

Comments

Popular posts from this blog

Run Workflow directly from a button in Dynamics 365 Customer Engagement V9.0

Use Audit Logs in Dynamics 365 : Actionable Audit