Power Community

Power Community

How to Use Create Operations in Microsoft Dataverse or MSCRM

image

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 🙂

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Announcing SharePoint Embedded General Availability

Authored by: Zach Rosenfield Today we’re pleased to announce the general availability of SharePoint Embedded, a new way to build...

More Articles Like This

- Advertisement -spot_img