在活动/任务屏幕(cr306020)中,有一个'相关实体'具有PXSelector查找的字段以及用于打开相关实体的屏幕的铅笔:
我想知道是否有办法为自定义字段执行此操作。我已经查看了该字段的源代码(它是DAC中的EPActivity.Source),但是我没有看到任何将这些属性放在该字段上的内容。没有PXSelector或类似的东西。
答案 0 :(得分:0)
以下示例显示如何在机会(CR304000)屏幕上添加“相关实体”字段。请注意,Acumatica Customization Manager中的布局编辑器当前不支持此示例中使用的PXRefNoteSelector控件。我使用机会来简化和缩短示例。不幸的是,现在您只能在自定义屏幕上添加“相关实体”字段。
现在让我们继续前进到示例:
实施CROpportunity DAC的扩展,以声明数据库绑定 UsrRefNoteID 和未绑定的 RelatedEntity 字段。相关实体的NoteID将存储在UsrRefNoteID中,而RelatedEntity将用于显示相关实体的用户友好描述:
public class CROpportunityExt : PXCacheExtension<CROpportunity>
{
#region UsrRefNoteID
public abstract class usrRefNoteID : IBqlField { }
protected Guid? _UsrRefNoteID;
[PXDBGuid]
[PXParent(typeof(Select<CRActivityStatistics,
Where<CRActivityStatistics.noteID, Equal<Current<CROpportunityExt.usrRefNoteID>>>>), LeaveChildren = true)]
public Guid? UsrRefNoteID
{
get
{
return _UsrRefNoteID;
}
set
{
_UsrRefNoteID = value;
}
}
#endregion
#region Source
public abstract class relatedEntity : IBqlField { }
[PXString(IsUnicode = true)]
[PXUIField(DisplayName = "Related Entity Description", Enabled = false)]
[PXFormula(typeof(EntityDescription<CROpportunityExt.usrRefNoteID>))]
public string RelatedEntity { get; set; }
#endregion
}
为OpportunityMaint BLC创建扩展,以使用PXRefNoteSelectorAttribute修饰其主机会数据视图。编辑(铅笔)和查找按钮需要PXRefNoteSelectorAttribute才能处理您的自定义相关实体字段:
public class OpportunityMaintExt : PXGraphExtension<OpportunityMaint>
{
[PXCopyPasteHiddenFields(typeof(CROpportunity.resolution))]
[PXViewName(Messages.Opportunity)]
[PXRefNoteSelector(typeof(CROpportunity), typeof(CROpportunityExt.usrRefNoteID))]
public PXSelect<CROpportunity> Opportunity;
}
在Aspx页面上,添加PXRefNoteSelector控件并将 DataField 属性设置为 RelatedEntity 和 NoteIDDataField 到 UsrRefNoteID 。 对于 EditButton , LookupButton 和 LookupPanel 标记,请使用使用PXRefNoteSelector属性修饰的主数据视图名称(商机在下面的代码片段中)
<pxa:PXRefNoteSelector ID="edRefEntity" runat="server" DataField="RelatedEntity" NoteIDDataField="UsrRefNoteID"
MaxValue="0" MinValue="0" ValueType="Guid" CommitChanges="true">
<EditButton CommandName="Opportunity$Navigate_ByRefNote" CommandSourceID="ds" />
<LookupButton CommandName="Opportunity$Select_RefNote" CommandSourceID="ds" />
<LookupPanel DataMember="Opportunity$RefNoteView" DataSourceID="ds" TypeDataField="Type" IDDataField="NoteID" />
</pxa:PXRefNoteSelector>
隐藏表单工具栏中PXRefNoteSelector属性生成的3个操作。使用与PXRefNoteSelector属性相同的主数据视图名称(下面的代码段中的 Opportunity ),如上所示:
<CallbackCommands>
...
<px:PXDSCallbackCommand Name="Opportunity$Navigate_ByRefNote" Visible="False" />
<px:PXDSCallbackCommand Name="Opportunity$Select_RefNote" Visible="False" />
<px:PXDSCallbackCommand Name="Opportunity$Attach_RefNote" Visible="False" />
</CallbackCommands>
您可能还需要实现自己的 EntityDescription 运算符,因为在创建此示例时,它具有内部访问修饰符,并且在PX外部不可用.Objects.dll:
public class EntityDescription<RefNoteID> : BqlFormulaEvaluator<RefNoteID>, IBqlOperand
where RefNoteID : IBqlField
{
public override object Evaluate(PXCache cache, object item, Dictionary<Type, object> pars)
{
Guid? refNoteID = (Guid?)pars[typeof(RefNoteID)];
return new EntityHelper(cache.Graph).GetEntityDescription(refNoteID, item.GetType());
}
}
最后...自定义机会屏幕的屏幕截图,其中包含全新的相关实体字段: