Wednesday, 7 January 2026

What's New in SharePoint Framework (SPFx): Latest Features and Updates

Introduction to SharePoint Framework (SPFx)

The SharePoint Framework (SPFx) is a modern development model for building custom solutions in SharePoint Online and on-premises. It enables developers to create responsive, mobile-friendly web parts and extensions using popular web technologies like React, Angular, and TypeScript. In this article, we’ll explore what’s new in SPFx and how these updates can enhance your SharePoint development experience.

Key New Features in SPFx

Microsoft continuously improves SPFx to provide developers with better tools and capabilities. Here are some of the latest updates:

  • Support for Microsoft Teams: SPFx now allows developers to build apps that work seamlessly in both SharePoint and Microsoft Teams, improving collaboration and integration.
  • Improved Performance: The latest versions of SPFx include optimizations for faster load times and better resource management, ensuring a smoother user experience.
  • Yarn and NPM Compatibility: Developers can now use Yarn or NPM for package management, offering flexibility in managing dependencies.
  • Enhanced Tooling: Updated Yeoman generators and Gulp tasks make scaffolding and building projects easier than ever.

Benefits of the Latest SPFx Updates

The new features in SPFx bring several benefits to developers and organizations:

  • Cross-Platform Development: Build solutions that work across SharePoint Online, on-premises, and Microsoft Teams.
  • Modern Web Standards: Leverage React, Angular, and other frameworks for creating dynamic, responsive solutions.
  • Faster Deployment: Improved build processes and performance optimizations reduce time-to-market for custom solutions.

Examples of SPFx Use Cases

Here are some practical examples of how organizations use SPFx:

  • Custom Web Parts: Create tailored web parts for dashboards, reports, and interactive content.
  • Extensions: Add custom actions, field customizers, and application customizers to enhance SharePoint functionality.
  • Teams Integration: Build apps that provide a unified experience across SharePoint and Microsoft Teams.

Conclusion

The latest updates in SharePoint Framework (SPFx) make it a powerful tool for modern SharePoint development. By leveraging these new features, developers can create more efficient, integrated, and user-friendly solutions. Stay updated with SPFx releases to maximize your SharePoint investment.

What's New in .NET Core: Latest Features and Enhancements for Developers

Introduction to What's New in .NET Core

The latest updates in .NET Core bring powerful features and performance improvements that developers have been waiting for. Whether you are building web applications, APIs, or microservices, understanding what's new in .NET Core can help you stay ahead in the development world.

Key Features in the Latest .NET Core Release

The new version of .NET Core introduces several enhancements that improve productivity, security, and performance. Here are some of the most notable updates:

  • Improved Performance: The runtime and libraries have been optimized for faster execution and reduced memory usage.
  • Cross-Platform Support: Enhanced compatibility for Linux, macOS, and Windows environments.
  • New APIs: Additional APIs for better integration and functionality in modern applications.
  • Enhanced Security: Built-in security features to protect against common vulnerabilities.

Benefits of Upgrading to the Latest .NET Core

Upgrading to the latest .NET Core version ensures that your applications are future-proof and take advantage of the newest technologies. Some benefits include:

  • Better performance and scalability for enterprise applications.
  • Access to modern development tools and frameworks.
  • Long-term support and regular security updates.

Example: Building a Web API with .NET Core

Creating a Web API in .NET Core is now easier than ever. With the new templates and simplified configuration, developers can quickly set up RESTful services that are fast, secure, and maintainable.

Conclusion

Staying updated with what's new in .NET Core is essential for developers who want to build high-performing, secure, and scalable applications. Explore the latest features today and take your development skills to the next level.

Tuesday, 6 January 2026

How to Create a Polymorphic Column in Dataverse: A Complete Guide

What is a Polymorphic Column in Dataverse?

A polymorphic column in Dataverse is a special type of column that can reference multiple tables instead of being limited to a single table. This feature is particularly useful when you need flexibility in your data model, allowing a single column to store references to different entity types without creating multiple lookup fields.

Why Use Polymorphic Columns?

Polymorphic columns provide several benefits for developers and businesses:

  • Flexibility: They allow a single column to relate to multiple tables, reducing complexity.
  • Efficiency: Simplifies data relationships and reduces the need for redundant fields.
  • Scalability: Ideal for scenarios where the related entity can vary, such as activities linked to different record types.

Steps to Create a Polymorphic Column in Dataverse

Follow these steps to create a polymorphic column in Microsoft Dataverse:

  • Step 1: Navigate to the Power Apps Maker Portal and select your environment.
  • Step 2: Open the Tables section and choose the table where you want to add the column.
  • Step 3: Click on Add Column and select Lookup as the data type.
  • Step 4: In the Related Table dropdown, choose Activity or Customer to enable polymorphic behavior. These are the two primary polymorphic relationships supported by Dataverse.
  • Step 5: Save and publish your changes to make the column available in your apps and flows.

Best Practices for Using Polymorphic Columns

To ensure optimal performance and maintainability, consider these best practices:

  • Use polymorphic columns only when necessary to avoid unnecessary complexity.
  • Document the relationships clearly for future reference.
  • Test your apps thoroughly to ensure the column behaves as expected across different scenarios.

By following these steps and best practices, you can effectively create and manage polymorphic columns in Dataverse, enhancing the flexibility and scalability of your data model.

Monday, 5 January 2026

What is SharePoint Embedded and Its New Features?

SharePoint Embedded is a modern, API-first platform designed to help developers integrate Microsoft 365 content management capabilities directly into their applications. Unlike traditional SharePoint, which focuses on site-based collaboration, SharePoint Embedded provides a headless, scalable solution for building custom content experiences without the overhead of full SharePoint sites.

What is SharePoint Embedded?

SharePoint Embedded is a cloud-based service that allows developers to leverage Microsoft 365's secure file storage, compliance, and collaboration features within their own apps. It is built on the same trusted infrastructure as SharePoint and OneDrive, ensuring enterprise-grade security and compliance while offering flexibility for custom development.

Key Benefits of SharePoint Embedded

  • API-First Architecture: Enables developers to create custom content solutions without relying on SharePoint UI.
  • Scalability: Designed to handle large-scale content storage and management for enterprise applications.
  • Security and Compliance: Inherits Microsoft 365’s robust security, compliance, and governance features.
  • Seamless Integration: Easily integrates with Microsoft Graph and other Microsoft 365 services.

New Features in SharePoint Embedded

Microsoft has introduced several new features to make SharePoint Embedded more powerful and developer-friendly:

  • Multi-Tenant Support: Build apps that can serve multiple organizations securely.
  • Granular Permissions: Fine-tuned access control for files and folders within your application.
  • Enhanced API Capabilities: Improved endpoints for file operations, metadata management, and search.
  • Cost-Effective Storage: Flexible pricing models for large-scale content storage needs.

Why Choose SharePoint Embedded?

If you are building an application that requires secure document storage, compliance, and collaboration features without the complexity of a full SharePoint site, SharePoint Embedded is the ideal solution. It empowers developers to create tailored experiences while leveraging Microsoft’s trusted infrastructure.

By adopting SharePoint Embedded, businesses can accelerate development, reduce infrastructure costs, and deliver modern, secure content solutions to their users.

SharePoint Document Management System: The Ultimate Guide for Businesses

What is a SharePoint Document Management System?

A SharePoint Document Management System (DMS) is a powerful solution designed to help businesses organize, store, and manage documents efficiently. Built on Microsoft SharePoint, this system provides a centralized platform for document collaboration, version control, and secure access, making it an essential tool for modern enterprises.

Key Features of SharePoint DMS

SharePoint offers a wide range of features that make document management seamless and effective. Here are some of the most notable capabilities:

  • Centralized Storage: All documents are stored in a single, secure location, reducing duplication and confusion.
  • Version Control: Track changes and maintain a history of document revisions for better accountability.
  • Access Control: Define user permissions to ensure sensitive information is only accessible to authorized personnel.
  • Collaboration Tools: Enable real-time co-authoring and communication within documents.
  • Integration: Seamlessly integrates with Microsoft 365 apps like Teams, Outlook, and OneDrive.

Benefits of Using SharePoint for Document Management

Implementing a SharePoint Document Management System can transform the way your organization handles information. Here are some key benefits:

  • Improved Productivity: Employees can quickly find and share documents, reducing time spent searching for files.
  • Enhanced Security: Advanced encryption and compliance features protect sensitive data.
  • Scalability: Suitable for businesses of all sizes, from small teams to large enterprises.
  • Cost Efficiency: Reduces the need for physical storage and minimizes operational costs.

Best Practices for Implementing SharePoint DMS

To maximize the benefits of SharePoint, follow these best practices:

  • Plan Your Structure: Organize libraries and folders logically to make navigation easy.
  • Set Clear Permissions: Define roles and access levels to maintain security and compliance.
  • Train Your Team: Ensure employees understand how to use SharePoint effectively for document management.
  • Leverage Automation: Use workflows to automate repetitive tasks like approvals and notifications.

By implementing a SharePoint Document Management System, businesses can streamline operations, enhance collaboration, and ensure data security. Whether you are a small business or a large enterprise, SharePoint DMS is a smart investment for efficient document management.

Tuesday, 7 October 2025

What’s New and Coming to SharePoint in 2025

What’s New and Coming to SharePoint in 2025 🚀

Microsoft is continuing to evolve SharePoint with AI-powered innovation, better integration across Microsoft 365, and smarter admin tools. Here’s a summary of all the key new features and updates coming to SharePoint in 2025.

1. AI and Copilot Enhancements

SharePoint is getting deeper Copilot integration to make page authoring and collaboration faster and more intelligent. You’ll be able to generate new sections on pages using AI prompts, with Copilot suggesting layouts, images, and text automatically. The text editor now supports a “Refine” feature—just tell Copilot to make your writing more formal, concise, or friendly. A new AI-driven FAQ web part makes it simple to add and manage question-and-answer content on intranet sites.
SharePoint Agents are also coming—custom AI assistants that can answer questions about your content, integrate with Teams, and be governed with analytics and permission controls. Plus, a new “Agent Link” web part lets you add an AI assistant directly to your SharePoint pages.

2. Smarter Sharing and Permissions

A new “Hero Link” sharing experience simplifies how files are shared and helps eliminate multiple confusing links. Bulk permission editing is being introduced, allowing you to adjust access for multiple files or folders in one go. When sharing a file, Copilot can even generate a short summary of the content to help recipients understand what’s inside before opening it.

3. Document Library and Automation Upgrades

Document libraries are becoming more powerful with new rule actions like “copy file to,” “move file to,” and “set content type.” SharePoint eSignature is rolling out globally (except in a few regions), letting you send and track electronic signatures directly within SharePoint. Signed documents from Adobe or DocuSign will now save back to the original folder automatically. Microsoft Purview adds OCR (optical character recognition) for scanning images inside files like PDFs or Word docs to detect sensitive information. There’s also a new workflow that allows secure deletion of Copilot artifacts while respecting retention and compliance policies.

4. Governance and Admin Improvements

SharePoint Advanced Management (SAM) introduces deeper governance, including lifecycle policies, permission reports, and agent monitoring. Admins will have better controls for throttling and performance management across sites and apps. Site attestation and enhanced analytics give admins visibility into inactive or overshared sites, helping reduce sprawl and improve security.

5. Experience and Analytics Enhancements

The SharePoint experience is getting more modern and measurable. Page analytics will now include click-through rates (CTR), so you can see how users interact with links on a page—not just page views. News posts will display estimated read times both on the web and within Viva Connections. Navigation and mobile responsiveness are being refined, along with improved site headers and footers. Video experiences are also unifying across SharePoint, Stream, and OneDrive for a seamless media experience.

6. Deprecations and Transitions

Some older features are being phased out or replaced. SPFx Field Customizers are planned for deprecation around mid-2026, with Microsoft encouraging migration to Column Formatting or modern alternatives. Microsoft Lists mobile apps (iOS and Android) will be retired, pushing users toward browser-based access. Stream Classic continues its transition into the newer Clipchamp-based video experience. Admins using Entra B2B for external sharing should note that existing external links may need to be re-shared once integrations are updated.

Preparing for the Future of SharePoint

These changes show Microsoft’s clear direction: a smarter, more AI-driven SharePoint that integrates deeply with Copilot, Teams, and Microsoft 365. To prepare:

  1. Monitor feature rollouts through your Microsoft 365 admin center and the official SharePoint Roadmap.

  2. Pilot new AI tools with a small group before full rollout.

  3. Review governance policies to align with new sharing, retention, and agent features.

  4. Train authors and power users to use Copilot responsibly and efficiently.

  5. Plan migrations for any deprecated tools or apps.

SharePoint’s 2025 roadmap focuses on simplicity, automation, and intelligence—empowering users and admins alike to create better digital workplaces.


Monday, 22 April 2024

how to pass data from child component to parent component

 

1. Create a child component with props 

handleCallBackProp?:(data:string)=> void;

set the value in props on button click or change or where you want to update the parent component

 props.handleCallBackProp!("Chield Value");


2. Now go to parent component and create a call back function like below

  const handleCallBack=(value:string)=>{    alert(value); } 

add the props con the child component like below

handleCallBackProp={handleCallBack}

Monday, 9 October 2023

Monday, 25 September 2023

PCF Control development




1. Install the Node.js
2. Open the Power shell and run node -v
3. Download and Install the Visual Studio Code
4. Install the Power Apps CLI
5. Validate the PowerApps CLI    pac install latest 
6. Create a PCF Project 
    . Create your own folder in your local machine
    . Open a cmd prompt and change the location to above created.
    . Execute the following command syntax is    
          pac pcf init --namespace CRMONCE --name CRMPCFProject --template field

7. run the command     npm install
8. Open the folder in VSCode.
9. run npm run build 
10 run    "npm start"/ "npm start watch"
For continues solution build 


Use below url if you get ssl error
http://127.0.0.1:8181/

To generate package use below command

pac solution init --publisher-name developer --publisher-prefix dev
go to directory
C:\Users\user\Downloads\PCFPackage
pac solution add-reference --path "C:\Users\user\Documents\ProjectPCFControl"
open VS Developer command and run below command
first time below command
msbuild /t:build /restore
next time for production use below command else
msbuild /p:configuration=Release
msbuild

PCF Control Schema

 Control TAG 


Attributes of control tags  

namespace: Provided in the “pac” command earlier. 

constructor: Provided in the “pac” command earlier. 

version: change the versioning if needed; else, we can keep it to default. 

display-name-key: This will be the display name with no spaces for custom control. 

description-key: This description will be shown in D365 for custom control. 

control-type: We will keep the default value 


Property TAG

Attributes of property tags 

name: Provide the name that will be used for custom control. 

display-name-key: Provide the display name with no spaces for custom control. 

description-key: This description will be shown in D365 for custom control. 

of-type: If we are using a single datatype, then there are some supported datatype that can be used for the of-type attribute. 

Valid values are: 


TwoOptions 

Whole.None 

Currency 

DateAndTime.DateAndTime 

DateAndTime.DateOnly 

SingleLine.Email 

SingleLine.Phone 

SingleLine.Text 

SingleLine.TextArea 

SingleLine.Ticker 

SingleLine.URL 

Decimal 

Enum 

FP 

Multiple 

Optionset 

of-type-group: if we are building control that will support multiple data-type, then we need to use the of-type-group attribute.  

Let us define a type-group: 


<type-group name=”line”> 

<type>SingleLine.Email</type> 

<type>SingleLine.Phone</type> 

<type>SingleLine.Text</type> 

<type>SingleLine.URL</type> 

</type-group> 



DataSet TAG

 Attributes of data-set tags 

name: Provide the name of the data setused to get the value in a custom control. 

display-name-key: Provide the display name with no spaces that will be set while importing in App. 

description-key: This description will be shown in D365 for custom control. 


Resources TAG 


Subtags of Resources tags 

code: Provide the relative path for typescript file which contains code for custom control 

css – Provide the CSS files that need to be added. 

resx – Provide the file path that contains static string contents that are needed for the control. 

img – Provide the images that are needed in the project. 

Thursday, 21 September 2023

How to get other controls value in PCF Control

 

 // @ts-ignore
           let XRM:any=window['Xrm'];
           let lastName=XRM.Page.data._formContext.getControl("cr6a2_lastname").getValue();

Wednesday, 20 September 2023

error 'context' is defined but never used no-unused-vars

 

When we run npm run build or npm start command and getting below error  

[4:53:53 PM] [start]  Initializing...

[4:53:53 PM] [start]  Validating manifest...

[4:53:53 PM] [start]  Validating control...

[4:53:55 PM] [start]  Generating manifest types...

[4:53:55 PM] [start]  Generating design types...

[4:53:55 PM] [start]  Running ESLint...

[4:53:59 PM] [start]  Failed:

[pcf-1065] [Error] ESLint validation error:

 43:23  error  'context' is defined but never used  no-unused-vars


Solution: Then ".eslintrc.json" file and add the below configuration under rules.


 "rules": {
      "no-unused-vars": ["warn"],
      "no-undef": ["warn"]
    }

React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration

When we  build the PCF project and  receive below warning  

Error:

Warning: React version not specified in eslint-plugin-react settings. See https://github.com/jsx-eslint/eslint-plugin-react#configuration .

[4:47:40 PM] [start]  Compiling and bundling control...



Solution : Open the ".eslintrc.json" and add below configuration 


"settings": {

      "react": {

        "version": "detect"

      }

    }



The OutputPath property is not set for project PCFPackage.cdsproj

 When we run the below command in VS Developer command 


"msbuild /t:build /restore" or "msbuild /p:configuration=Release"

and get the below error

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(780,5): error : The OutputPath property is not set for project 'PCFPackage.cdsproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='AnyCPU'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\Users\user\Downloads\PCFPackage\PCFPackage.cdsproj]


Solution: Add below configuration in .cdsproj file 


<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

    <DebugSymbols>true</DebugSymbols>

    <DebugType>full</DebugType>

    <Optimize>false</Optimize>

    <OutputPath>bin\Debug\</OutputPath>

    <DefineConstants>DEBUG;TRACE</DefineConstants>

    <ErrorReport>prompt</ErrorReport>

    <WarningLevel>4</WarningLevel>

  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">

    <DebugType>pdbonly</DebugType>

    <Optimize>true</Optimize>

    <OutputPath>bin\Release\</OutputPath>

    <DefineConstants>TRACE</DefineConstants>

    <ErrorReport>prompt</ErrorReport>

    <WarningLevel>4</WarningLevel>

  </PropertyGroup>



Monday, 14 August 2023

Transaction in Dataverse using console application

 public static void DataverseConnector()

        {

            try

            {

                string conn = @"AuthType=OAuth;Username=abcd@org.onmicrosoft.com;Password=password;Url=https://dorg.crm.dynamics.com;TokenCacheStorePath=c:\temp\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                        // Create an ExecuteTransactionRequest object.

                        var requestToCreateRecords = new ExecuteTransactionRequest()

                        {

                            // Create an empty organization request collection.

                            Requests = new OrganizationRequestCollection(),

                            ReturnResponses = true

                        };


                        // Create several (local, in memory) entities in a collection. 

                        var listData = new List<string>();

                        listData.Add("Account 1");

                        listData.Add("Account 2");

                        listData.Add("Account 3");

                        listData.Add("Account 4");

                        listData.Add("43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51");

                        // Add a CreateRequest for each entity to the request collection.

                        foreach (var list in listData)

                        {

                            OrganizationRequest organizationRequest = new OrganizationRequest();

                            Entity accEntity;

                            accEntity = new Entity("account");

                            accEntity["name"] = list;

                            if (list == "43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51")

                            {

                                organizationRequest.RequestName = "Update";

                                accEntity["name"] = "Update record";

                                accEntity.Id = new Guid("43b1e6dc-8e3a-ee11-bdf4-000d3a0aab51");

                            }

                            else

                            {

                                organizationRequest.RequestName = "Create";

                            }

                            organizationRequest.Parameters.Add("Target", accEntity);

                            requestToCreateRecords.Requests.Add(organizationRequest);

                        }

                        // Execute all the requests in the request collection using a single web method call.

                        try

                        {

                            var responseForCreateRecords =(ExecuteTransactionResponse)serviceClient.Execute(requestToCreateRecords);

                            // Display the results returned in the responses.

                            foreach (var responseItem in responseForCreateRecords.Responses)

                            {

                                if (responseItem != null)

                                {

                                    if (responseItem.ResponseName == "Create")

                                    {

                                        Console.WriteLine(responseItem.ResponseName + " with account id as " + responseItem.Results["id"].ToString());

                                    }

                                    else if (responseItem.ResponseName == "Update")

                                    {

                                        Console.WriteLine(responseItem.ResponseName);

                                    }

                                }

                            }

                        }

                        catch (FaultException<OrganizationServiceFault> ex)

                        {

                            Console.WriteLine("Create request failed for the account{0} and the reason being: {1}",

                                ((ExecuteTransactionFault)(ex.Detail)).FaultedRequestIndex + 1, ex.Detail.Message);

                            throw;

                        }

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }

Friday, 11 August 2023

Disassociate a record in dataverse using console application

  public static void DataverseConnector()

        {

            try

            {

               string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                        // Retrieve the accounts

                        var query = new QueryByAttribute("account")

                        {

                            ColumnSet = new ColumnSet("name")

                        };

                        query.AddAttributeValue("address1_city", "Redmond");

                        EntityCollection accounts = serviceClient.RetrieveMultiple(query);

                        //Convert the EntityCollection to a EntityReferenceCollection

                        var accountReferences = new EntityReferenceCollection();


                        accounts.Entities.ToList().ForEach(x => {

                            accountReferences.Add(x.ToEntityReference());

                        });


                        // The contact to associate to the accounts

                        var contacttoAssociateWithAccount = new EntityReference("contact",new Guid("edb87117-ce7e-ed11-81ab-000d3ac9cc70"));


                        // The relationship to use

                        var relationship = new Relationship("account_primary_contact");


                        // Use the Associate method

                        serviceClient.Disassociate(contacttoAssociateWithAccount.LogicalName, contacttoAssociateWithAccount.Id, relationship, accountReferences);

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }

Associate a record in dataverse using console application

  public static void DataverseConnector()

        {

            try

            {

                string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                        // Retrieve the accounts

                        var query = new QueryByAttribute("account")

                        {

                            ColumnSet = new ColumnSet("name")

                        };

                        query.AddAttributeValue("address1_city", "Redmond");

                        EntityCollection accounts = serviceClient.RetrieveMultiple(query);

                        //Convert the EntityCollection to a EntityReferenceCollection

                        var accountReferences = new EntityReferenceCollection();


                        accounts.Entities.ToList().ForEach(x => {

                            accountReferences.Add(x.ToEntityReference());

                        });


                        // The contact to associate to the accounts

                        var contacttoAssociateWithAccount = new EntityReference("contact",new Guid("edb87117-ce7e-ed11-81ab-000d3ac9cc70"));


                        // The relationship to use

                        var relationship = new Relationship("account_primary_contact");


                        // Use the Associate method

                        serviceClient.Associate(contacttoAssociateWithAccount.LogicalName, contacttoAssociateWithAccount.Id, relationship, accountReferences);

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }

Retrieve data from dataverse in paging using console application

  public static void DataverseConnector()

        {

            try

            {

               string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                        RetriveRecords(serviceClient);

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }

        private static void RetriveRecords(ServiceClient serviceClient)

        {

            int queryCount = 3;

            int pageNumber = 1;

            int recordCount = 0;

            QueryExpression pagequery = convertFecthXMLToQueryExpression(serviceClient);

            pagequery.PageInfo = new PagingInfo();

            pagequery.PageInfo.Count = queryCount;

            pagequery.PageInfo.PageNumber = pageNumber;

            // The current paging cookie. When retrieving the first page, 

            // pagingCookie should be null.

             pagequery.PageInfo.PagingCookie = null;

            Console.WriteLine("Retrieving account records in pages...\n");

            while (true)

            {

                // Retrieve the page.

                EntityCollection results = serviceClient.RetrieveMultiple(pagequery);

                if (results.Entities != null)

                {

                    // Retrieve all records from the result set.

                    foreach (var acct in results.Entities)

                    {

                        Console.WriteLine("{0}.\t{1}", ++recordCount, acct["name"]);

                    }

                }

                // Check for more records, if it returns true.

                if (results.MoreRecords)

                {

                    Console.WriteLine("\n****************\nPage number {0}\n****************", pagequery.PageInfo.PageNumber);

                    // Increment the page number to retrieve the next page.

                    pagequery.PageInfo.PageNumber++;

                    // Set the paging cookie to the paging cookie returned from current results.

                    pagequery.PageInfo.PagingCookie = results.PagingCookie;

                }

                else

                {

                    // If no more records are in the result nodes, exit the loop.

                    break;

                }

            }

        }

        private static QueryExpression convertFecthXMLToQueryExpression(ServiceClient serviceClient)

        {

            var query = @"<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/><attribute name='numberofemployees'/></entity></fetch>";

            FetchXmlToQueryExpressionRequest fetchToQueryExpRequest = new FetchXmlToQueryExpressionRequest();

            fetchToQueryExpRequest.FetchXml = query;

            FetchXmlToQueryExpressionResponse fetchXmlToQueryExpressionResponse = (FetchXmlToQueryExpressionResponse)serviceClient.Execute(fetchToQueryExpRequest);

            QueryExpression myquery = fetchXmlToQueryExpressionResponse.Query;

            return myquery;

        }


other way to fetch item using FetchXML in paging


https://learn.microsoft.com/en-us/power-apps/developer/data-platform/org-service/page-large-result-sets-with-fetchxml



Thursday, 10 August 2023

Delete a record from Dataverse table using console application

 public static void DataverseConnector()

        {

            try

            {

                string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                       serviceClient.Delete("account", new Guid("a17f700a-6d37-ee11-bdf4-000d3a0aab51"));                       

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }

RetrieveMultiple records from dataverse using console application

 public static void DataverseConnector()

        {

            try

            {

               string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";

                using (ServiceClient serviceClient = new ServiceClient(conn))

                {

                    if (serviceClient.IsReady)

                    {

                      var  query = @"<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/><attribute name='numberofemployees'/></entity></fetch>";

                       var recordColl= serviceClient.RetrieveMultiple(new FetchExpression(query));

                        foreach (var accountrecord in recordColl.Entities)

                        {

                              Console.WriteLine(accountrecord.Id);

                              Console.WriteLine(accountrecord["name"]);

                              Console.WriteLine(accountrecord["numberofemployees"]);

                        }

                    }

                    else

                    {

                        Console.WriteLine("A web service connection was not established.");

                    }

                }

                // Pause the console so it does not close.

                Console.WriteLine("Press any key to exit.");

                Console.ReadLine();

            }

            catch (Exception ex)

            {

                Console.Write(ex.Message);

            }

            

        }