Introduction:
In this Blog we will see how to use Create Operations in Microsoft Dataverse or MSCRM environment.
Implementation Steps:
As I mentioned in my Previous Blog you can able to follow how to use Dataverse Connection with Console Application.
In this Blog we will see how to use Create Operation in Dataverse
Copy and Paste the below Code for Create Operations
static void Main(string[] args)
{
// Connection string to Dynamics 365
string connectionString = "AuthType=Office365;Url=https://URL.crm8.dynamics.com/;Username=username@environment.onmicrosoft.com;RequireNewInstance=true;Password=PASSWORD;";
// Create the CrmServiceClient instance using the connection string
CrmServiceClient service = new CrmServiceClient(connectionString);
// Check if the connection was successful
if (!service.IsReady)
{
Console.WriteLine("Failed to connect to Dynamics 365.");
return;
}
else
{
Entity createAccount = new Entity("account");
createAccount["name"] = "Demo Account";
createAccount["OPTION SET LOGICAL NAME"] = new OptionSetValue(10000);
createAccount["ENTITY REFERENCE LOGICAL NAME"] = new EntityReference("Entity LogicalName", new Guie(GUID OF RECORD));
service.Create(createAccount);
}
}
"account" --> Table Name
"name" --> Logical Name of field Name
OptionSetValue --> to set Drop Down Values
EntityReference --> LookUp Reference.
That's it
No comments:
Post a Comment