Can some one help me here with sample piece of code
Can some one help me here with sample piece of code
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);
}
Hey.
Have you checked the links posted? PaulBO has posted direct links. Also, the GitHub from SeanMcNellis (github.com/.../UserOperations) has samples
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
Can you please give me more sample on this
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,
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
André Arnaud de Cal...
292,865
Super User 2025 Season 1
Martin Dráb
231,723
Most Valuable Professional
nmaenpaa
101,156
Moderator