如何从 Note Table 获取 DAC 记录
How to get DAC record from Note Table
当我不知道音符附加到哪种 dac 类型时,有人有关于如何从 RefNoteId => DAC 转到的代码片段吗?
我已经做到了(row.RefNoteID 是我的起点)
Note note = PXSelect<Note, Where<Note.noteID, Equal<Required<Note.noteID>>>>.Select(this, row.RefNoteID);
Type recordType = Type.GetType(note.EntityType);
PXCache recordCache = Caches[recordType];
我现在如何做 PXSelect>>>.Select(GRAPH) ? recordType 可以是系统中具有 noteID 的任何 DAC。
谢谢
下面的代码对我有用,它基于 Acumatica 在 PXRefNoteSelectorAttribute.PrimaryRow_RowPersisted
.
中获取记录的方式
这种方法的问题在于,它适用于 Header 实体,如 SOOrder、INRegister、SOInvoice、SOShipment 等。但是对于“详细”实体,如 SOLine、INTran 和其他实体,只有当对应的记录有一些与 Text/File 相关的注释时,这种方法才有效。只有当详细记录有一些 Note/Text 时,Acumatica 才会将与其 NoteID 对应的记录添加到注释 table 中。我最好的猜测是这样做是为了避免 over-spamming Note table.
using PX.Data;
using PX.Objects.SO;
using System;
using System.Collections;
using System.Linq;
using System.Web.Compilation;
namespace SearchByNoteID
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> searchByNoteID;
[PXUIField(DisplayName ="Search by Note ID")]
[PXButton(CommitChanges = true)]
public virtual IEnumerable SearchByNoteID(PXAdapter adapter)
{
var order = adapter.Get<SOOrder>().FirstOrDefault();
if(order!=null)
{
//
//...
//
Guid? noteID = GetNoteID();
object record = GetRecordByNoteID(noteID);
//
//... do whatever you want with the record
//
}
return adapter.Get();
}
protected object GetRecordByNoteID(Guid? noteID)
{
var type = GetEntityType(this.Base, noteID);
if(type==null) return null;
object entityRow = new EntityHelper(this.Base).GetEntityRow(type, noteID);
return entityRow;
}
protected Type GetEntityType(PXGraph graph, Guid? noteID)
{
if (noteID == null)
{
return null;
}
Note note = PXSelectBase<Note, PXSelect<Note, Where<Note.noteID, Equal<Required<Note.noteID>>>>.Config>.SelectWindowed(graph, 0, 1, new object[]
{
noteID
});
if (note == null || string.IsNullOrEmpty(note.EntityType))
{
return null;
}
return PXBuildManager.GetType(note.EntityType, false);
}
}
}
当我不知道音符附加到哪种 dac 类型时,有人有关于如何从 RefNoteId => DAC 转到的代码片段吗?
我已经做到了(row.RefNoteID 是我的起点)
Note note = PXSelect<Note, Where<Note.noteID, Equal<Required<Note.noteID>>>>.Select(this, row.RefNoteID);
Type recordType = Type.GetType(note.EntityType);
PXCache recordCache = Caches[recordType];
我现在如何做 PXSelect
谢谢
下面的代码对我有用,它基于 Acumatica 在 PXRefNoteSelectorAttribute.PrimaryRow_RowPersisted
.
这种方法的问题在于,它适用于 Header 实体,如 SOOrder、INRegister、SOInvoice、SOShipment 等。但是对于“详细”实体,如 SOLine、INTran 和其他实体,只有当对应的记录有一些与 Text/File 相关的注释时,这种方法才有效。只有当详细记录有一些 Note/Text 时,Acumatica 才会将与其 NoteID 对应的记录添加到注释 table 中。我最好的猜测是这样做是为了避免 over-spamming Note table.
using PX.Data;
using PX.Objects.SO;
using System;
using System.Collections;
using System.Linq;
using System.Web.Compilation;
namespace SearchByNoteID
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> searchByNoteID;
[PXUIField(DisplayName ="Search by Note ID")]
[PXButton(CommitChanges = true)]
public virtual IEnumerable SearchByNoteID(PXAdapter adapter)
{
var order = adapter.Get<SOOrder>().FirstOrDefault();
if(order!=null)
{
//
//...
//
Guid? noteID = GetNoteID();
object record = GetRecordByNoteID(noteID);
//
//... do whatever you want with the record
//
}
return adapter.Get();
}
protected object GetRecordByNoteID(Guid? noteID)
{
var type = GetEntityType(this.Base, noteID);
if(type==null) return null;
object entityRow = new EntityHelper(this.Base).GetEntityRow(type, noteID);
return entityRow;
}
protected Type GetEntityType(PXGraph graph, Guid? noteID)
{
if (noteID == null)
{
return null;
}
Note note = PXSelectBase<Note, PXSelect<Note, Where<Note.noteID, Equal<Required<Note.noteID>>>>.Config>.SelectWindowed(graph, 0, 1, new object[]
{
noteID
});
if (note == null || string.IsNullOrEmpty(note.EntityType))
{
return null;
}
return PXBuildManager.GetType(note.EntityType, false);
}
}
}