I'm facing a validation issue when trying to use the CopyChildLink attribute on a field that has its selector overridden in CacheAttached.
[PXRemoveBaseAttribute(typeof(ARInvoiceType.AdjListAttribute))]
[ARInvoiceTypeExt.AdjList]
protected virtual void _(Events.CacheAttached<ARPaymentTotals.adjdDocType> e)
{
}
[PXRemoveBaseAttribute(typeof(ARInvoiceType.AdjdListAttribute))]
[ARInvoiceTypeExt.AdjdList]
protected virtual void _(Events.CacheAttached<ARAdjust.adjdDocType> e)
{
}
[PXMergeAttributes(Method = MergeMethod.Replace)]
[PXDBString(15, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
[PXDefault]
[PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.Visible)]
[ARInvoiceType.AdjdRefNbr(typeof(Search2<ARInvoice.refNbr,
LeftJoin<ARAdjust, On<ARAdjust.adjdDocType, Equal<ARInvoice.docType>,
And<ARAdjust.adjdRefNbr, Equal<ARInvoice.refNbr>,
And<ARAdjust.released, NotEqual<True>,
And<ARAdjust.voided, NotEqual<True>,
And<Where<ARAdjust.adjgDocType, NotEqual<Current<ARRegister.docType>>,
Or<ARAdjust.adjgRefNbr, NotEqual<Current<ARRegister.refNbr>>>>>>>>>,
LeftJoin<ARAdjust2, On<ARAdjust2.adjgDocType, Equal<ARInvoice.docType>,
And<ARAdjust2.adjgRefNbr, Equal<ARInvoice.refNbr>,
And<ARAdjust2.released, NotEqual<True>,
And<ARAdjust2.voided, NotEqual<True>>>>>,
LeftJoin<Customer, On<ARInvoice.customerID, Equal<Customer.bAccountID>>,
LeftJoin<SOInvoice, On<ARInvoice.docType, Equal<SOInvoice.docType>, And<ARInvoice.refNbr, Equal<SOInvoice.refNbr>>>>>>>,
Where<ARInvoice.docType, Equal<Optional<ARAdjust.adjdDocType>>,
And2<Where<ARInvoice.released, Equal<True>,
Or<ARInvoice.origModule, Equal<BatchModule.moduleSO>,
And<ARInvoice.docType, NotEqual<ARDocType.creditMemo>>>>,
And<ARInvoice.openDoc, Equal<True>,
And<ARInvoice.hold, Equal<False>,
And<ARAdjust.adjgRefNbr, IsNull,
And2<Where<ARAdjust2.adjdRefNbr, IsNull, Or<ARInvoice.docType, Equal<ARDocType.prepaymentInvoice>>>,
And2<Where<ARInvoice.docType, NotEqual<ARDocType.prepaymentInvoice>, Or<ARInvoice.pendingPayment, Equal<True>>>,
And<ARInvoice.customerID, In2<Search<PX.Objects.AR.Override.BAccount.bAccountID,
Where<PX.Objects.AR.Override.BAccount.bAccountID, Equal<Optional<ARRegister.customerID>>,
Or<PX.Objects.AR.Override.BAccount.consolidatingBAccountID, Equal<Optional<ARRegister.customerID>>>>>>,
And2<Where<ARInvoice.pendingPPD, NotEqual<True>,
Or<Current<ARRegister.pendingPPD>, Equal<True>>>,
And<Where<
Current<ARSetup.migrationMode>, NotEqual<True>,
Or<ARInvoice.isMigratedRecord, Equal<Current<ARRegister.isMigratedRecord>>>>>>>>>>>>>>>), Filterable = true)]
[CopyChildLink(typeof(ARPaymentTotals.invoiceCntr), typeof(ARAdjust.curyAdjdAmt),
new Type[] { typeof(ARAdjust.adjdDocType), typeof(ARAdjust.adjdRefNbr) },
new Type[] { typeof(ARPaymentTotals.adjdDocType), typeof(ARPaymentTotals.adjdRefNbr) })]
protected virtual void _(Events.CacheAttached<ARAdjust.adjdRefNbr> e)
{
}
The Problem: When the CopyChildLink attribute is present, I get the following error: Error: [AdjdRefNbr] 'XXXXXXX' cannot be found in the system.
If I comment out the [CopyChildLink] attribute, the error disappears and the selector works perfectly, allowing me to select the document. It seems like CopyChildLink triggers a validation that fails because the document doesn't match the selector's strict Where criteria at the moment of linking, or it interferes with how the cache handles the record.