I am attempting to use PXForeignReference on a DAC extension to ensure the field is set to null when the referenced document is deleted. It published fine but doesn’t work. Is this possible?
(NOTE: at the moment, ReferenceBehavior is ‘Restrict’ which should throw an exception upon deleting)
public class DSDPMCostBudget_Ext : PXCacheExtension<PX.Objects.PM.PMCostBudget>
{
public static bool IsActive() => true;
#region UsrPDPOType
PXDBString(2, IsUnicode = true)]
POOrderType.List()]
PXDefault(POOrderType.ProjectDropShip, PersistingCheck = PXPersistingCheck.Nothing)]
PXUIField(DisplayName = "PO Type")]
public virtual string UsrPDPOType { get; set; }
public abstract class usrPDPOType : BqlString.Field<usrPDPOType> { }
#endregion
#region UsrPDPONbr
PXDBString(15, IsUnicode = true)]
PO.RefNbr(typeof(Search2<POOrder.orderNbr,
LeftJoinSingleTable<Vendor, On<POOrder.vendorID, Equal<Vendor.bAccountID>,
And<Match<Vendor, Current<AccessInfo.userName>>>>>,
Where<POOrder.orderType, Equal<Optional<usrPDPOType>>,
And<Vendor.bAccountID, IsNotNull>>,
OrderBy<Desc<POOrder.orderNbr>>>), Filterable = true)]
// Here's the foreign reference
PXForeignReference(typeof(CompositeKey<
Field<usrPDPOType>.IsRelatedTo<POOrder.orderType>,
Field<usrPDPONbr>.IsRelatedTo<POOrder.orderNbr>>), ReferenceBehavior.Restrict)]
PXUIField(DisplayName = "PO Nbr")]
public virtual string UsrPDPONbr { get; set; }
public abstract class usrPDPONbr : BqlString.Field<usrPDPONbr> { }
#endregion
}