How to search an Order's Notes ?

Discussions related to custom development with Select.
Post Reply
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

How to search an Order's Notes ?

Post by toddsou »

Hi-

SPS version 4.3.10.1

I am needing to iterate through an open Order's Notes and look at each Note's content for specific strings.

I have something like this, but the Cast to INote throws, as the items in the collection are not derived from INote.

Code: Select all

var notes = _activeOrder["Notes"] as IList;
var lookingForMyFavoriteNote = notes.Cast<INote>().FirstOrDefault(note =>
{
   if (note.Content.StartsWith("this", StringComparison.InvariantCultureIgnoreCase) ||
      note.Content..StartsWith("that", StringComparison.InvariantCultureIgnoreCase))
   {
      return true;
   }
   
   return false;
}
I put a breakpoint after the "notes = ....." line and inspected the result via trying to evaluate notes[0].GetType(), and the response was that it was a Type called Note, but the namespace was not defined, so I wasn't sure how to go about drilling down to each Note's Content.

?

Thank you.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: How to search an Order's Notes ?

Post by BobRichards »

Like many items in the order, each note is an IOrderItem and you can access all the properties easily.

Code: Select all

IList notes = (IList)order.GetProperty("Notes");
foreach (IOrderItem note in notes)
{
    string text = (string)note.GetProperty("Text");
}
Bob Richards, Senior Software Developer, SoftPro
Post Reply