【问题标题】:How to get DAC record from Note Table如何从 Note Table 中获取 DAC 记录
【发布时间】:2021-01-22 04:05:15
【问题描述】:

当我不知道笔记附加到什么 dac 类型时,是否有人有关于如何从 RefNoteId => DAC 转到的代码 sn-p?

我已经做到了这一点(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


    【解决方案1】:

    以下代码适用于我,它基于 Acumatica 获取 PXRefNoteSelectorAttribute.PrimaryRow_RowPersisted 内记录的方式。

    这种方法的问题在于,这将适用于 SOOrder、INRegister、SOInvoice、SOSshipment 等 Header 实体。但对于 SOLine、INTran 等“详细”实体,只有在相应记录有一些与文本/文件相关的注释时,这种方法才有效。 Acumatica 仅当详细记录有一些注释/文本时,才会将与其 NoteID 对应的记录添加到注释表中。我最好的猜测是这样做是为了避免过度发送 Note 表。

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

    【讨论】:

    • 感谢 Samvel!幸运的是,我可以强制为通过此过程的任何记录创建笔记。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 2014-11-21
    • 2021-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多