'Error when deleting GenericArguments[0], 'PX.Data.Current`1[PX.Objects.PO.POReceipt+receiptNbr]
When I delete, I have this error :
GenericArguments[0], 'PX.Data.Current`1[PX.Objects.PO.POReceipt+receiptNbr]', on
'PX.Data.Current`1[Field]' violates the constraint of type 'Field'.
The grid works correctly, we have this error only when we delete the reception
#region ReceiptNbr
[PXDBString(15, IsUnicode = true, InputMask = "",IsKey=true)]
[PXUIField(DisplayName = "Receipt Nbr")]
[PXDBDefault(typeof(POReceipt.receiptNbr))]
[PXParent(typeof(Select<POReceipt, Where<POReceipt.receiptNbr, Equal<Current<POReceipt.receiptNbr>>>>))]
public virtual string ReceiptNbr { get; set; }
public abstract class receiptNbr : PX.Data.BQL.BqlString.Field<receiptNbr> { }
#endregion
if I put this, it's ok but the record stay in database :
[PXParent(typeof(Select<POReceipt, Where<POReceipt.receiptNbr, Equal<Current<POReceipt.receiptNbr>>>>),LeaveChildren = true)]
The dateview is :
#region Data Views
public PXSelect<POReceiptcolis,Where<POReceiptcolis.receiptNbr,Equal<Current<POReceiptcolis.receiptNbr>>>> CurrentPOReceiptcolisvue;
public PXSave<POReceiptcolis> Save;
public PXCancel<POReceiptcolis> Cancel;
#endregion
Solution 1:[1]
You aren't providing table names, so I will start with and explain an example from my code. Your use of PXParent is incorrect as you are telling it the parent is "where the receipt number of the parent record matches the parent's current receipt number".
Instead, consider this example. I have 2 tables. SSRQRequisition (Parent) and SSRQLine (Child). In SSRQLine, I do 3 things... first, I set the field as a Key field, as is typical in Parent/Child relationships. You have done this. Second, I setup PXDBDefault to set the value to the parent's matching field, as you have done as well. Third, and this is the part you will need to correct, I tell the DAC that it is related to the parent by the CHILD'S current requisition number.
#region RequisitionID
[PXDBInt(IsKey = true)]
[PXDBDefault(typeof(SSRQRequisition.requisitionID))]
[PXParent(
typeof(Select<SSRQRequisition,
Where<SSRQRequisition.requisitionID,
Equal<Current<SSRQLine.requisitionID>>>>)
)]
[PXUIField(DisplayName = Messages.FldRequisitionID)]
public virtual int? RequisitionID { get; set; }
public abstract class requisitionID : PX.Data.BQL.BqlInt.Field<requisitionID> { }
#endregion
If your parent record is POReceipt, your PXParent should be:
[PXParent(
typeof(Select<POReceipt,
Where<POReceipt.receiptNbr,
Equal<Current<ThisDAC.receiptNbr>>>>)
)]
... where you would substitute your DAC's name for ThisDAC.
This will result in telling Acumatica that the Parent of ThisDAC is through the ReceiptNbr field of ThisDAC and to go find the POReceipt with the matching ReceiptNbr value. Additionally, as a Parent/Child relationship, this will also have Acumatica delete the child record (as attached via Current<ThisDAC.receiptNbr>) when the parent is deleted. Instead of registering ThisDAC as a child of POReceipt, you effectively asked Acumatica to register POReceipt as a child of itself as you wrote it.
Hope this makes sense and helps.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Brian Stevens |

