Skip to main content
Solved

Error saving child detail records

  • November 14, 2024
  • 2 replies
  • 27 views

I have a Tab form. The main form and first tab sho details from DAC1. Tab 2 contains a grid for records from DAC2.

I have the following views in my graph

 

public SelectFrom<DAC1>.View DAC1;
public SelectFrom<DAC1>.Where<DAC1.dac1ID.IsEqual<DAC1.dac1ID.FromCurrent>>.View DAC1Detail;
public SelectFrom<DAC2>.Where<DAC2.dac1ID.IsEqual<DAC1.dac1ID.FromCurrent>>.View DAC2;

 

The foreign key referecens in DAC2 is defined as 

#region Dax1ID
[PXDBInt()]
[PXUIField(DisplayName = "DAX1 ID")]        
[PXDefault(typeof(DAX1.dax1ID))]
[PXParent(typeof(SelectFrom<DAX1>.Where<DAX1.dax1ID.IsEqual<DAX2.dax1ID.FromCurrent>>))]
public virtual int? Dax1ID { get; set; }
public abstract class dax1ID : PX.Data.BQL.BqlInt.Field<dax1ID> { }
#endregion

 

If I add a new DAC1 and then save it and then edit the DAC2 grid all works well.

If I add a new DAC1 edit it, then add details to the DAC2 grid and then save it, the DAC2 records are assigned to the wrong dac1ID. If I look in the database I can see the Dac1ID field contains -2147483647

 

Clearly I’ve missed something. I’ve been through the T210 training document a couple of times, but the scenarios do not quite match what I’m doing.

 

Any help would be greatly appreciated.

Best answer by jumble0470

So my error was PXDefault instead of PXDBDefault. Once I updated the DAC all was working correctly. Thanks for your help.

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+1
  • Jr Varsity I
  • 62 replies
  • November 15, 2024
  • Added proper identity handling for DAC1: [PXDBIdentity]
  • Modified the parent reference in DAC2 to use proper default: [PXDBDefault(typeof(DAC1.dac1ID))]
  • Added RowPersisting event handler to ensure child records are marked for update when parent is inserted
  • Added RowPersisted event handler to update child records with the correct parent ID after the parent record is saved
  • Added LineNbr field to DAC2 for proper record ordering
  • Added OrderBy clause to the DAC2 view for consistent record ordering

  • Author
  • Freshman II
  • 1 reply
  • Answer
  • November 18, 2024

So my error was PXDefault instead of PXDBDefault. Once I updated the DAC all was working correctly. Thanks for your help.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings