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 New Note in sales order

(0) ShareShare
ReportReport
Posted on by

Hi,

I m using dynamic crm 2015 and i want to create new note in sales order 

here is my code

var note = new Annotation()
{
Subject = "Note subject...",
NoteText = "Note Details....",
// DocumentBody = Convert.ToBase64String(data),
// FileName = Path.GetFileName(attachment.Name),
MimeType = "text/plain",
Id = Guid.NewGuid(),
// Associate the note to the contact.
ObjectId = newsalesorder.ToEntityReference(),
ObjectTypeCode = SalesOrder.EntityLogicalName
};

_orgContext.AddObject(note);

_orgContext.AddLink(newsalesorder, new Relationship("SalesOrder_Annotation"), note);

In this i am getting all the vlalue in note but still it gives me error of null reference  in

 _orgContext.AddObject(note);

How can i achieve this?

*This post is locked for comments

  • RE: How to create New Note in sales order

    Thank you guido,

    I solved my problem.

    i want to ask that what is the difference between orgService and orgContext.

    And

    _orgContext.AddLink(newsalesorder, new Relationship("SalesOrder_Annotation"), note);

    and if am using orgContext then i have to specify relationship between salesorder and note??and if I am using orgservice i need to write this relationship?

  • RE: How to create New Note in sales order

    Hi,

    I am getting null in ObjectId = newsalesorder.ToEntityReference()..but why ?
    I am not able to understand

    Here is my Code

    SalesOrder newsalesorder = new SalesOrder
    {
    Name = txtName.Text,
    Description = txtdescription.Text,
    CustomerId = new EntityReference
    {
    LogicalName = Account.EntityLogicalName,
    Id = _accountId.Value
    },
    PriceLevelId = new EntityReference
    {
    Id = (dynamic)_priceListId,
    Name = "PriceLevel"
    },
    BillTo_Line1 = txtstreet1.Text,
    BillTo_Line2 = txtstreet2.Text,
    BillTo_Line3 = txtstreet3.Text,
    BillTo_City = txtcity.Text,
    BillTo_StateOrProvince = txtstate.Text,
    BillTo_PostalCode = txtzipcode.Text,
    BillTo_Country = txtcountry.Text,

    ShipTo_Line1 = txtshipstreet1.Text,
    ShipTo_Line2 = txtshipstreet2.Text,
    ShipTo_Line3 = txtshipstreet3.Text,
    ShipTo_City = txtshipcity.Text,
    ShipTo_StateOrProvince = txtshipstate.Text,
    ShipTo_PostalCode = txtshipzipcode.Text,
    ShipTo_Country = txtshipcountry.Text,

    BillTo_ContactName = "Harshit shah",
    TotalTax = new Money(30.0M),
    DiscountAmount = new Money(60.0M),
    };

    _salesOrderId = _orgService.Create(newsalesorder);

    var note = new Annotation()
    {
    Subject = "Note subject...",
    NoteText = "Note Details....",
    MimeType = "text/plain",
    ObjectId = newsalesorder.ToEntityReference()
    };

    _orgContext.AddObject(note);

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,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,430 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans