Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to insert field value from csv file to Entity using plugin code?

Posted on by 160

I just attach CSV file in note section form an entity. Then after attached csv file in note section , whatever the data in csv file just insert  in to entity fields using plugin.

*This post is locked for comments

  • ggghj Profile Picture
    ggghj 160 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    I have a doubt about to get id of attached file in note section.

    Share with u code details , at the time click on ribbon button the attached csv file from note section carry data and insert it into entity fields.

    $('#infg.infg_mta.Button2.Button').on("click",function(e){

       e.preventDefault();

       $('#files').parse({

           config: {

               delimiter: "auto",

               complete: buildTable,

           },

           before: function(file, inputElem)

           {

               //console.log("Parsing file...", file);

           },

           error: function(err, file)

           {

               //console.log("ERROR:", err, file);

           },

           complete: function()

           {

               //console.log("Done with all files");

           }

       });

    });

    function buildTable(results){

       var markup = "<table class='table'>";

       var data = results.data;

       for(i=0;i<data.length;i++){

           markup+= "<tr>";

           var row = data[i];

           var cells = row.join(",").split(",");

           for(j=0;j<cells.length;j++){

               markup+= "<td>";

               markup+= cells[j];

               markup+= "</th>";

           }

           markup+= "</tr>";

       }

       markup+= "</table>";

       $("#app").html(markup);

    }

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    You might actually try to re-use import functionality. There is an example here:

    https://msdn.microsoft.com/en-us/library/hh547396.aspx

    I think Aric has already provided you a link explaining the document attachments..

    https://msdn.microsoft.com/en-us/library/gg328429.aspx

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    Here are some links to help you start, but as Pawel mentioned, there are a lot of links your can search online:

    // Reading CSV file. You will have to modify reading for directory to reading from stream

    stackoverflow.com/.../reading-csv-files-using-c-sharp

    // MSDN Upload Retrieve and Download attachment

    msdn.microsoft.com/.../gg328429.aspx;MSPPError=-2147217396

    // MSDN Use Entity class for create update and delete

    msdn.microsoft.com/.../gg309731.aspx

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    As I said - there are thousands of links. Just copy paste to Google search each of the step that I posted and choose whichever you will find suitable and clear enough for you.

  • ggghj Profile Picture
    ggghj 160 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    Ok,

    Can you please share some referral link.

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: How to insert field value from csv file to Entity using plugin code?

    Do you already have some code for a starting point? Which part are you having problem with? There are thousands examples on google on

    1) How to create a plugin in CRM 2016

    2) How to read document from an Annotation in CRM 2016

    3) How to read CSV file

    4) How to update record in CRM 2016

    Just put it all together and you will have your solution. Don't expect others to do all the job for you, how fun is it if you don't try to figure something out for yourself at first? If you already have and it's not working then post your code, we will be happy to help you make it work.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans