void sender_RowPersisted(PXCache sender, PXRowPersistedEventArgs e) { if (!IsSearchable(sender, e.Row)) { return; } Guid?noteID = (Guid?)sender.GetValue(e.Row, _FieldOrdinal); Dictionary <Guid, SearchIndex> dict = PX.Common.PXContext.GetSlot <Dictionary <Guid, SearchIndex> >("SearchIndexSlot"); if (dict == null) { dict = new Dictionary <Guid, SearchIndex>(); PX.Common.PXContext.SetSlot("SearchIndexSlot", dict); } SearchIndex si = null; if (noteID.HasValue) { dict.TryGetValue(noteID.Value, out si); if (si == null) { Note note = PXSelect <Note, Where <Note.noteID, Equal <Required <Note.noteID> > > > .SelectSingleBound(sender.Graph, null, noteID); si = BuildSearchIndex(sender, e.Row, null, note != null ? note.NoteText : null); dict[noteID.Value] = si; } } if (e.TranStatus == PXTranStatus.Completed) { if (noteID == null) { throw new PXException(MsgNotLocalizable.SearchIndexCannotBeSaved); } if (e.Operation == PXDBOperation.Delete) { PXDatabase.Delete(typeof(SearchIndex), new PXDataFieldRestrict(typeof(SearchIndex.noteID).Name, PXDbType.UniqueIdentifier, si.NoteID)); } else { if (!Update(si)) { Insert(si); } } } }