首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从备注表中获取DAC记录

如何从备注表中获取DAC记录
EN

Stack Overflow用户
提问于 2021-01-21 01:56:05
回答 1查看 40关注 0票数 0

当我不知道注释附加到哪种类型的DAC时,谁有关于如何从RefNoteId => dac转到的代码片段?

我已经走到这一步了(row.RefNoteID就是我的起点)

代码语言:javascript
运行
复制
        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];  

我现在如何执行Equal>>>.Select(GRAPH)、Where

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-21 18:10:47

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

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

代码语言:javascript
运行
复制
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);
        }
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65814976

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档