Monday, July 31, 2023

How to Use Retrieve Operation in Dataverse using Console Application

Introduction:


In this Blog we will see how to use Retrieve Operation in Dataverse using Console Applicaiton


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 Retrieve Operation in Dataverse

 

Copy paste the Below Code

 

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 retrieveAccount = service.Retrieve("account", new Guid("e5c5f9b6-6b2f-ee11-bdf4-002248d5d764"),
                    new Microsoft.Xrm.Sdk.Query.ColumnSet(true));

                string accountName = retrieveAccount.Attributes["name"].ToString();
                EntityReference AccountOwner = (EntityReference)retrieveAccount.Attributes["ownerid"];
            }
        }

 

In the above snippet you will see 

 

"account" --> Logical Name of the Table

"e5c5f9b6-6b2f-ee11-bdf4-002248d5d764" --> Guid of the Record

Microsoft.Xrm.Sdk.Query.ColumnSet(true) --> (true) to retrieve all the Records from the table

retrieveAccount.Attributes["name"].ToString() --> Retrieve Name of the Record from the Account Table

(EntityReference)retrieveAccount.Attributes["ownerid"] --> Retrieve Owner of the Record from the Account Table



Video : https://youtu.be/9td8eyx1hkc

Monday, July 24, 2023

How to Connect Dataverse with Console Application

Introduction:


In this Blog we will see how to Connect Dataverse with Console Application.


Implementation Steps:

 

1. Open Visual Studio

 

2. Search for .Net Framework

 

rampprakash_0-1690195194751.png

 

 

3. Select Next 

 

rampprakash_2-1690195235634.png

 

4. Input your Name and Click Create

 

5. It will Create a Console Application Project

 

6. Once Created Input the Below Code

 

try
                {
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                    CrmServiceClient conn = CrmServiceClient(ConfigurationManager.ConnectionStrings["Xrm"].ConnectionString.Decrypt());
                    conn = new CrmServiceClient("AuthType=Office365;Url=https://URL.crm4.dynamics.com/;Username=USERNAME;Password=PASSWORD;RequireNewInstance=True");

                    if (conn.IsReady)
                    {
// Connection Established
                    }
else{
// Connection Not Established
}

                    return conn;
                }
                catch (Exception ex)
                {
                    throw;
                }

 

7. Once you pasted above code you will get error like below (ITS because of Missing Assembly)

 

rampprakash_3-1690195604096.png

 

 

8. Right Click on the error CRMServiceClient you will get Quick Actions Select and Select Install Package Microsoft.CrmSdk.XrmTooling.CoreAssembly

 

rampprakash_4-1690195717821.png

 

9. Once Done it will automatically install all the Respective Assembly 

 

rampprakash_5-1690195762223.png

 

 

That's it :slightly_smiling_face:

 

Once done you are good to go with the CRM Connection and process.

 

Note:

 

We can use Client ID and Client Secret as well to establish Connection

How to Import Data from Excel to Multiple tables in PowerApps

Introduction:   I have created a view on how to import data from excel to multiple tables in Canvas PowerApps   Implemented Steps: ...