Skip to main content
Answer

Error during Persist around an unbound DAC

  • October 14, 2024
  • 3 replies
  • 189 views

Forum|alt.badge.img+7

I have an unbound DAC that I’m using to display ARSalesPrice records in a grid in a pop-up screen. It works fine.

The SalesPricesView view I’m using for the grid uses a public IEnumerable routine to collect and populate the view.

After .Inserting the records into the view, I call SalesPricesView.Cache.IsDirty = false;

When the pop-up screen is closed, I call SalesPricesView.Cache.Clear();

Now when I try to save the order and I’m calling the base Persist I get this error:

The table schema of the MyDACTable table was not found in the cache. The table is locked by another process. Please try again later.

MyDACTable is made up of all Unbound fields and has the [PXVirtual] attribute.  The view definition is:

[PXVirtualDAC]

public PXSelect<MyDACTable> SalesPricesView;

 

I don’t why Persist would care that the MyDACTable table was in the cache since it isn’t being asked to save anything.

Best answer by Naveen Boga

@Django  Understood that you declared attribute [VirtualDAC].

Is there any reason for not declaring your unbound DAC view with the PXFilter instead of PXSelect?

public PXFilter<MyDACTable> SalesPricesView;

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • October 15, 2024

@Django  Understood that you declared attribute [VirtualDAC].

Is there any reason for not declaring your unbound DAC view with the PXFilter instead of PXSelect?

public PXFilter<MyDACTable> SalesPricesView;


Forum|alt.badge.img+2

Hi @Django 

I’ve had issues with the PXVirtual family of attributes as well.  One thing you can try is canceling the database operations for your DAC with a RowPersisting event:

protected virtual void _(Events.RowPersisting<MyDACTable> e) => e.Cancel = true;

 


Forum|alt.badge.img+7
  • Author
  • Captain II
  • October 15, 2024

@Naveen Boga Thank you - that did the trick. I think I did not use PXFilter because of this statement in the Framework Guide:

The PXFilter data view always creates a single data record and never retrieves this data record or saves it to the database.

along with this boxed text in Yellow:

It is forbidden to use the PXFilter data view type with a DAC that has at least one key field defined —that is, a DAC that contains fields with the IsKey=true parameter in the type attribute.

So, between those two lines, I figured that I might have issues with multiple records and a grid control.

 

@stephenbologna39 Your solution also worked, so thank you for sharing that as well!

 

Given that I can’t select two answers I’ll just go Naveen’s based on timestamp.

 

And, for future me I also tried changing the view to be declared as:

public PXSelectReadOnly<MyDACTable> SalesPricesView;

but that did NOT work. The hint on PXSelectReadOnly said that it wouldn’t merge with the Cache so I thought that might do it.