web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to create a Note Using Plugin

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Verified answer
    KNK Profile Picture
    1,432 on at

    thanks u so much Guido Preite

  • KNK Profile Picture
    1,432 on at

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

  • KNK Profile Picture
    1,432 on at

    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);

                       }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans