Question

Discard Changes and Close does not clear the cache with Generic Inquiry

  • 26 January 2021
  • 5 replies
  • 101 views

I have a Generic Inquiry screen showing batches to post.  When I select a batch it brings up my form.  If I make any changes to the form and click Cancel button, I get a warning that my changes will be lost.  If I click to continue, the changes are undone. That works perfectly.

However, if I click Discard Changes and Close, I get a prompt that I will lose my changes.  I click ok to continue and it takes me back to the Generic Inquiry screen.  When I select that batch again, the form still reflects any changes I made to the Grid.  The Description field is in the form section and it DOES NOT get saved when I reselect the batch to edit.

At this point, if I refresh the browser, it redisplays everything as unchanged (good).

This is what it looks like before I change anything:

If I untick the Errors to clear them, I am updating the details records to clear the errors on the line

        protected void _(Events.FieldUpdated<ICSPending, ICSPending.hasErrors> e)
        {
            ICSPending row = e.Row;
            if (row.HasErrors == false)
            {
                e.Cache.SetValue<ICSPending.hasAccountError>(row, false);
                e.Cache.SetValue<ICSPending.hasSubaccountError>(row, false);
                e.Cache.SetValue<ICSPending.hasBranchError>(row, false);
            }
        }

When all rows are clear of errors, the “Batch Has Errors” is set to false and the checkbox is hidden.  I do this in the RowSelected of the header record

        protected void _(Events.RowSelected<ICSPendingHDR> e)
        {
            ICSPendingHDR row = e.Row;
            if (row == null) return;

            //check if any rows have errors
            bool rowhaserror = false;
            foreach (ICSPending iCSPending in Details.Select()) {
                if (iCSPending.HasErrors == true) rowhaserror = true;
            }

            Post.SetEnabled(row.Status == ICSEntryStatusConstants.Unposted &&
                 Headers.Cache.GetStatus(row) != PXEntryStatus.Inserted &&
                 !rowhaserror);

            e.Cache.SetValue<ICSPendingHDR.hasErrors>(row, rowhaserror);

            PXUIFieldAttribute.SetVisible<ICSPendingHDR.hasErrors>(e.Cache, row, rowhaserror);
        }
 

This is what it looks like if after I make changes:

After clicking Discard and reselecting the batch, this is what it looks like:

 

Note that the Description field did not persist but the changes I made to the Grid did.

Refreshing the browser will reset the form so it is back to its unchanged state.

How can I clear out the cache changes I made in the Grid when I click Discard Changes and Close?

Thanks,

Joe

 


5 replies

Userlevel 5
Badge +3

Hi Joe,

Are you updating the records in view delegate?

View Delegate will fire frequently on changes to the row, if you are updating the record in view delegate it shows the pop up as “Any unsaved changes will be discarded”. Please verify.

 

 

Hope this helps!!

 

 

Hi Naveen,  the records are just part of a filtered view

        public PXFilteredProcessing<ICSPendingHDR, ICSPendingHDRFilter,
               Where<ICSPendingHDR.status.IsEqual<ICSPendingHDRFilter.postedStatus.FromCurrent>>,
               OrderBy<Asc<ICSPendingHDR.glBatchNbr>>> EntriesToProcess;

The grid is bound to the EntriesToProcess view.  I am not using a view delegate.

Note, when I click Discard Changes and Close, I get all the normal “your going to lose your changes” dialogs but when I select the record again from the Generic Inquiry replacement form, the changes to the grid are still there. 

Refreshing the browser resets the grid.  Nothing is easy.  I looked at the IC3010PL generic inquiry but I don’t see anything there I should mark to reset the grid.  

Is it perhaps something to do with the DAC I selected for the PXCancel?

        public PXSave<ICSPendingHDRFilter> Save;
        public PXCancel<ICSPendingHDRFilter> Cancel;

 

Userlevel 5
Badge +3

Hi Joe,

Is this a processing screen or custom generic inquiry?

If this is a custom generic inquiry screen, then we use PXSelect<> view but NOT the PXFilteredProcesing view.

Processing views can be used in only in processing screens.

Hi Naveen,

In the heat of confusion, I copied the wrong select statements.  It was a really really long day…

It is just a regular editable form with a GI screen.

These are the select statements:

        public SelectFrom<ICSPendingHDR>.OrderBy<Desc<ICSPendingHDR.glBatchNbr>>.View Headers;

        public SelectFrom<ICSPending>.Where<ICSPending.glBatchNbr.IsEqual<ICSPendingHDR.glBatchNbr.FromCurrent>>
            .OrderBy<Asc<ICSPending.glBatchLineNbr>>
            .View Details;
 

I fixed the issue but it is not because I changed my code (much).

I changed this:

    public class ICSPendingEntries : PXGraph<ICSPendingEntries>
    {

        public PXSave<ICSPendingHDR> Save;
        public PXCancel<ICSPendingHDR> Cancel;
To:

    public class ICSPendingEntries : PXGraph<ICSPendingEntries, ICSPendingHDR>
    {

        //public PXSave<ICSPendingHDR> Save;
        //public PXCancel<ICSPendingHDR> Cancel;
 

By using all the default buttons, the Discard works as it should.  I originally did not use the default buttons on the graph because I don’t want them.

I will just hide them.

This seems like a bug to me.

 

 

Sorry for the churn.  The standard toolbar doesn’t make any difference.  It seemed to work for a couple tests but it is back to the unusual behavior.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved