Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

how to create a Note Using Plugin

Posted on by 1,432

hi all am trying to create note when account Creates using Plugin

i dont want to attach any files in Notes

just i want to trying a adding a text File.

when account Create Note Text File also Create 

if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];

// Verify that the target entity represents an account.
// If not, this plug-in was not registered correctly.
if (entity.LogicalName != "account")
return;

try
{
Entity _annotation = new Entity("annotation");
_annotation.Attributes["objectid"] = new EntityReference("account", new Guid("9ed7e828-fa70-e411-ba71-5453ed23c515"));
_annotation.Attributes["objecttypecode"] = "account";
_annotation.Attributes["mimetype"] = @"text/plain";
_annotation.Attributes["notetext"] = "Note is Created From Lead";

service.Create(_annotation);

}

Please Give me some Suggestion 

*This post is locked for comments

  • KNK Profile Picture
    KNK 1,432 on at
    RE: how to create a Note Using Plugin

    if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

               {

                   // Obtain the target entity from the input parameters.

                   Entity entity = (Entity)context.InputParameters["Target"];

                   if (entity.LogicalName == "account")

                   {

                       try

                       {

                           string strMessage = "this is a demo";

                           byte[] filename = Encoding.ASCII.GetBytes(strMessage);

                           string encodedData = System.Convert.ToBase64String(filename);

                           Entity Annotation = new Entity("annotation");

                           Annotation.Attributes["objectid"] = new EntityReference("account", new Guid("9ed7e828-fa70-e411-ba71-5453ed23c515"));

                           Annotation.Attributes["objecttypecode"] = 1;

                           Annotation.Attributes["subject"] = "account Demo File";

                           Annotation.Attributes["documentbody"] = Convert.ToBase64String(new UnicodeEncoding().GetBytes("Sample Annotation Text"));

                           Annotation.Attributes["mimetype"] = @"text/plain";

                           Annotation.Attributes["notetext"] = "Sample attachment.";

                          // Annotation.Attributes["filename"] = "Demo.txt";

                           service.Create(Annotation);

                       }

  • KNK Profile Picture
    KNK 1,432 on at
    RE: how to create a Note Using Plugin

    hi Guido Preite it is Not working am just Trying add Only a " Note text"

  • Verified answer
    KNK Profile Picture
    KNK 1,432 on at
    RE: how to create a Note Using Plugin

    thanks u so much Guido Preite

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans