我正在尝试在Acumatica中为自定义记录集实现继承的属性。尝试预览屏幕时,出现Null Reference Exception:System.NullReferenceException:对象引用未设置为对象的实例,并且无法与屏幕进行交互。
我将先前正在回答的问题基于Stack Overflow进行一些操作,但是我似乎无法使其在我的项目中正常工作。这是我使用的链接。 How to add Attribute Support to out-of-box Sales Order Entity? 和 Use of CSAttributes in new pages
“儿童” DAC代码段:
#region InvestmentFundTypeCD
[PXDBString(31, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Investment Fund Type CD")]
[PXSelector(typeof(InvestmentFundType.investmentFundTypeCD))]
public virtual string InvestmentFundTypeCD {get; set;}
public abstract class investmentFundTypeCD : IBqlField { }
#endregion
#region Attributes
public abstract class attributes : IBqlField { }
[CRAttributesField(typeof(InvestmentFund.investmentFundTypeCD))]
public virtual string[] Attributes { get; set; }
#endregion
“儿童”图段:
public class InvestmentFundForm : PXGraph<InvestmentFundForm, InvestmentFund>
{
public PXSelect<InvestmentFund> InvestmentFunds;
public CRAttributeList<InvestmentFund> Answers;
“父母”图形片段:
public class InvestmentFundTypeForm : PXGraph<InvestmentFundTypeForm, InvestmentFundType>
{
public PXSelect<InvestmentFundType> InvFundType;
public PXSelect<InvestmentFundType, Where<InvestmentFundType.investmentFundTypeCD,
Equal<Current<InvestmentFundType.investmentFundTypeCD>>>> CurInvestmentFundType;
[PXViewName("Attributes")]
public CSAttributeGroupList<InvestmentFundType, InvestmentFund> Mapping;
“儿童” ASPX代码段:
<px:PXTab DataMember="Answers" runat="server" ID="CstPXTab6">
<Items>
<px:PXTabItem Text="Attributes">
<Template>
<px:PXGrid runat="server" Height="200px" SkinID="Inquire" Width="100%"
ID="PXGridAnswers" Caption="Attributes" MatrixMode="True" DataSourceID="ds">
<AutoSize Enabled="True" MinHeight="200" ></AutoSize>
<ActionBar>
<Actions>
<Search Enabled="False" ></Search>
</Actions>
</ActionBar>
<Mode AllowAddNew="False" AllowDelete="False" AllowColMoving="False" ></Mode>
<Levels>
<px:PXGridLevel DataMember="Answers">
<Columns>
<px:PXGridColumn TextAlign="Left" DataField="AttributeID" TextField="Attributes" Width="80px"
AllowShowHide="False" ></px:PXGridColumn>
<px:PXGridColumn Type="CheckBox" TextAlign="Center" DataField="isRequired" Width="80px" ></px:PXGridColumn>
<px:PXGridColumn DataField="Value" Width="300px" AllowSort="False" AllowShowHide="False" ></px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
</px:PXGrid>
</Template>
</px:PXTabItem>
</Items>
</px:PXTab>
“父级” ASPX代码段:
<px:PXTab DataMember="CurInvestmentFundType" runat="server" ID="CstPXTab34">
<Items>
<px:PXTabItem Text="Attributes">
<Template>
<px:PXGrid runat="server" Height="150px" BorderWidth="0px" SkinID="Details"
Width="100%" ID="AttributesGrid" MatrixMode="True" DataSourceID="ds">
<AutoSize Container="Window" Enabled="True" MinHeight="150" ></AutoSize>
<Levels>
<px:PXGridLevel DataMember="Mapping">
<RowTemplate>
<px:PXSelector runat="server" ID="edAttributeID" DataField="AttributeID"
FilterByAllFields="True" AllowEdit="True" CommitChanges="True" ></px:PXSelector>
</RowTemplate>
<Columns>
<px:PXGridColumn DataField="AttributeID" Width="81px" AutoCallBack="True" LinkCommand="ShowDetails" ></px:PXGridColumn>
<px:PXGridColumn DataField="Description" Width="351px" AllowNull="False" ></px:PXGridColumn>
<px:PXGridColumn TextAlign="Right" DataField="SortOrder" Width="81px" ></px:PXGridColumn>
<px:PXGridColumn TextAlign="Center" Type="CheckBox" DataField="Required" AllowNull="False" ></px:PXGridColumn>
<px:PXGridColumn TextAlign="Center" Type="CheckBox" DataField="CSAttribute__IsInternal" AllowNull="True" ></px:PXGridColumn>
<px:PXGridColumn Type="DropDownList" DataField="ControlType" Width="81px" AllowNull="False" ></px:PXGridColumn>
<px:PXGridColumn RenderEditorText="False" DataField="DefaultValue" Width="100px" AllowNull="True" ></px:PXGridColumn>
</Columns>
</px:PXGridLevel>
</Levels>
</px:PXGrid>
</Template>
</px:PXTabItem>
</Items>
</px:PXTab>
我试图做的事情类似于客户类对客户所做的事情,我试图在两个对象之间继承属性。为“类”赋予一个属性,当将该“类”应用于继承者时,继承者将具有这些属性。知道我在做什么错吗?
编辑:添加到我的问题上,我们已经成功地使InvestmentFundType父实体存储了我们想要在InvestmentFund子实体上使用的属性。但是,当我们将公共类InvestmentFundPXExt添加到InvestmentFund代码时,会出现错误“找不到对象引用”。如果不进行说明,则会出现错误“值不能为空。参数名称:键”
InvestmentFund:
using System;
using PX.Data;
using PX.Objects.CR;
namespace Investments
{
[Serializable]
public class InvestmentFund : IBqlTable
{
#region InvestmentFundID
public abstract class investmentFundID : IBqlField { }
protected Int32? investFundID;
[PXDBIdentity]
public virtual Int32? InvestmentFundID { get{return this.investFundID;}
set{this.investFundID = value;} }
#endregion
#region InvestmentFundCD
public abstract class investmentFundCD : IBqlField { }
protected string invFundCD;
[PXDBString(51, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Investment Fund ID")]
[PXSelector(typeof(InvestmentFund.investmentFundCD),
typeof(InvestmentFund.investmentFundCD),
typeof(InvestmentFund.investFundDescription))]
public virtual string InvestmentFundCD {
get{
return this.invFundCD;
}
set{
this.invFundCD = value;
}
}
#endregion
#region InvestFundDescription
[PXDBString(101, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Invest Fund Description")]
public virtual string InvestFundDescription { get; set; }
public abstract class investFundDescription : IBqlField { }
#endregion
#region InvestmentFundTypeID
[PXDBInt]
[PXUIField(DisplayName = "Investment Fund Type ID")]
[PXSelector(typeof(Search<InvestmentFundType.investmentFundTypeID>),
typeof(InvestmentFundType.investmentFundTypeCD),
typeof(InvestmentFundType.investmentFundTypeDesc),
SubstituteKey=typeof(InvestmentFundType.investmentFundTypeCD))]
public virtual Int32? InvestmentFundTypeID { get; set; }
public abstract class investmentFundTypeID : IBqlField { }
#endregion
}
public class InvestmentFundPXExt : PXCacheExtension<InvestmentFund>
{
#region UsrAttributes
public abstract class usrAttributes : IBqlField
{
}
[CRAttributesField(typeof(InvestmentFund.investmentFundTypeID))]
public virtual string [] UsrAttributes { get; set; }
#endregion
}
}
我们已经想知道是否可以用非Acumatica实体实现Attributes了。有人做过吗?