Skip to main content
Answer

ForeignKeyOf Not displaying in DAC Browser

  • April 17, 2025
  • 1 reply
  • 42 views

Forum|alt.badge.img+8

Hello everyone,

 

I am developing a custom screen and ran into an issue. I have set up PrimaryKeyOf on the parent DAC, and ForeignKeyOf + PXParent + PXDBDefault on the child DAC, but this does not show up on the DAC schema browser. I noticed this because my PXFormula(...SumCalc<>) was not working.

Parent DAC:

[Serializable]
[PXCacheName("NPDHeader")]
[PXPrimaryGraph(typeof(NPDApprovalEntry))]
public class NPDHeader : PXBqlTable, IBqlTable
{
#region Keys
public class PK : PrimaryKeyOf<NPDHeader>.By<projectNo, productTitle>
{
public static NPDHeader Find(PXGraph graph, string projectNo, string productTitle, PKFindOptions options = PKFindOptions.None) => FindBy(graph, projectNo, productTitle, options);
}
public static class FK
{

}
#endregion

#region ProjectNo
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Project No", Enabled = false)]
[AutoNumber(typeof(ISOSetup.autoNumberingNPDApproval),
typeof(NPDHeader.date))]
[PXSelector(typeof(NPDHeader.projectNo),
typeof(NPDHeader.productTitle), ValidateValue = false)]
public virtual string ProjectNo { get; set; }
public abstract class projectNo : PX.Data.BQL.BqlString.Field<projectNo> { }
#endregion

#region ProductTitle
[PXDBString(128, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Product Title")]
[PXDefault]
public virtual string ProductTitle { get; set; }
public abstract class productTitle : PX.Data.BQL.BqlString.Field<productTitle> { }
#endregion




//Other Fields




#region TotalCost
public abstract class totalCost : BqlDecimal.Field<totalCost> { }

[PXDBDecimal(6)]
[PXFormula(null,
typeof(SumCalc<NPDDesignMatlCost.totalCost>))]
[PXDefault(TypeCode.Decimal, "0.00", PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Total Cost", Enabled = false)]
public virtual decimal? TotalCost
{
get;
set;
}
#endregion
}

Child DAC:

[Serializable]
[PXCacheName("NPDDesignMatlCost")]
public class NPDDesignMatlCost : PXBqlTable, IBqlTable
{
#region Keys
public class PK : PrimaryKeyOf<NPDDesignMatlCost>.By<projectNo, productTitle, matlLineNbr>
{
public static NPDDesignMatlCost Find(PXGraph graph, string projectNo, string productTitle, int matlLineNbr, PKFindOptions options = PKFindOptions.None) => FindBy(graph, projectNo, productTitle, matlLineNbr, options);
}
public static class FK
{
public class Approval : NPDHeader.PK.ForeignKeyOf<NPDDesignMatlCost>.By<projectNo, productTitle> { }
}
#endregion

#region ProjectNo
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Project No")]
[PXParent(typeof(FK.Approval))]
[PXDBDefault(typeof(NPDHeader.projectNo))]
public virtual string ProjectNo { get; set; }
public abstract class projectNo : PX.Data.BQL.BqlString.Field<projectNo> { }
#endregion

#region ProductTitle
[PXDBString(128, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Product Title")]
[PXDBDefault(typeof(NPDHeader.productTitle))]
public virtual string ProductTitle { get; set; }
public abstract class productTitle : PX.Data.BQL.BqlString.Field<productTitle> { }
#endregion

//Other Fields

}

DAC Schema Browser:

DAC Schema Browser Child DAC:

[Serializable]
[PXCacheName("NPDDependency")]
public class NPDDependency : PXBqlTable, IBqlTable
{
#region Keys
public class PK : PrimaryKeyOf<NPDDependency>.By<projectNo, productTitle, dependencyID>
{
public static NPDDependency Find(PXGraph graph, string projectNo, string productTitle, int dependencyID, PKFindOptions options = PKFindOptions.None) => FindBy(graph, projectNo, productTitle, dependencyID, options);
}
public static class FK
{
public class Approval : NPDHeader.PK.ForeignKeyOf<NPDDependency>.By<projectNo, productTitle> { }
}
#endregion

#region ProjectNo
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Project No")]
[PXParent(typeof(FK.Approval))]
[PXDBDefault(typeof(NPDHeader.projectNo))]
public virtual string ProjectNo { get; set; }
public abstract class projectNo : PX.Data.BQL.BqlString.Field<projectNo> { }
#endregion

#region ProductTitle
[PXDBString(128, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Product Title")]
[PXDBDefault(typeof(NPDHeader.productTitle))]
public virtual string ProductTitle { get; set; }
public abstract class productTitle : PX.Data.BQL.BqlString.Field<productTitle> { }
#endregion

//Other Fields

}

Does anyone have any idea as to how/why this is happening?

Best answer by darylbowman

It looks like you have PXFormula on the parent DAC field. I believe it goes on the child DAC field that is supposed to be summed and references the parent DAC field which shows the sum.

1 reply

darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • April 18, 2025

It looks like you have PXFormula on the parent DAC field. I believe it goes on the child DAC field that is supposed to be summed and references the parent DAC field which shows the sum.