Create and Associate Records in a single operation using Xrm.WebAPI in D365 Customer Engagement
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.
2. Also an opportunity is associated to the account as shown below in the associated view.
Hope this helped!
Comments
Post a Comment