Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

read csv or excel and create and also update record in D365 use console application

(0) ShareShare
ReportReport
Posted on by 5

Can some one help me here with sample piece of code

  • Suggested answer
    Mohan Kumar  Profile Picture
    90 on at
    RE: read csv or excel and create and also update record in D365 use console application

    The below piece of code should help you to read the csv file and use the data to create/update records

    private void ReadCSV(IOrganizationService orgService)

    {

       string path = txt_filepath.Text; //path of csv file

       string[] lines = System.IO.File.ReadAllLines(path);

       foreach (string line in lines)

       {

           string[] columns = line.Split(',');

           string value1 = columns[0];

           string value2 = columns[1];

           string value3 = columns[2];

           Create_record(value1, value2, value3, orgService);

       }

    }

    private void Create_record(string value1, string value2, string value3, IOrganizationService orgService)

    {

       Entity e = new Entity("EntityName");

       e["field1"] = value1;

       e["field2"] = value2;

       e["field3"] = value3;

       orgService.Create(e);

    }

  • Suggested answer
    PerezAguiar Profile Picture
    on at
    RE: read csv or excel and create and also update record in D365 use console application

    Hey.

    Have you checked the links posted?  PaulBO has posted direct links. Also, the GitHub from SeanMcNellis (github.com/.../UserOperations) has samples

  • theebika Profile Picture
    5 on at
    RE: read csv or excel and create and also update record in D365 use console application

    can you please give me more insight on this may be sample piece of code for example to read from excel and create records into dynamics

  • theebika Profile Picture
    5 on at
    RE: read csv or excel and create and also update record in D365 use console application

    Can you please give me more sample on this

  • Suggested answer
    PerezAguiar Profile Picture
    on at
    RE: read csv or excel and create and also update record in D365 use console application

    Hey!

    On https://github.com/seanmcne you have a powershell module created by Sean McNellis.  Also you have some samples of code there.  A few of those samples show how to read data from files and insert into dynamics (at least inserting/creating users).  Might be worth taking a look...

    regards,

  • Paul_Bo Profile Picture
    70 on at
    RE: read csv or excel and create and also update record in D365 use console application

    Hi theebika,

    Have you looked at any of the Sample code from the Microsoft documentation?  There is quite a bit there for updating and inserting records.  Here is a link to some basic functions:

    docs.microsoft.com/.../early-bound-entity-operations

    You can combine this with the following and you should get what you need.

    docs.microsoft.com/.../how-to-read-from-a-text-file

    Paul

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans