Solved

PXProcessing dialog shows Remaining until all records are processed

  • 6 October 2022
  • 4 replies
  • 137 views

Userlevel 6
Badge +3

I have a processing page to “mass delete” empty customer records.  On the processing dialog, it shows the Remaining count as the total count of the records being processed until ALL items have been completed.  Then, the Processed count shows all 3 items processed successfully after they are ALL complete.

I’m being a bit picky here, but I want the Processed count incremented and the Remaining count decremented after each record is processed.

When you click the PROCESS ALL button, this is where it starts out

 

After processing is complete for all 3 records, it shows this:

 

This is an example of my code:

		public static void DoIt(List<ICSMCCustomersToProcess> custList, bool? deleteCustomer)
{

foreach (ICSMCCustomersToProcess cust in custList)
{
try
{
bool? customerNotDeleted;
string errorMessage;

var graph = PXGraph.CreateInstance<DeleteCustomers>();
graph.Clear();
graph.DeleteCustomer(cust, out customerNotDeleted, out errorMessage, deleteCustomer, true);

//default
PXProcessing<ICSMCCustomersToDelete>.SetProcessed();

//override 1
if (customerNotDeleted == true)
{
PXProcessing<ICSMCCustomersToDelete>.SetWarning(custList.IndexOf(cust), "Customer was unable to be deleted");
}

//override 2
if (errorMessage != "")
{
PXProcessing<ICSMCCustomersToDelete>.SetError(custList.IndexOf(cust), errorMessage);
}
}
catch (Exception e)
{
PXProcessing<ICSMCCustomersToDelete>.SetError(custList.IndexOf(cust), e);
}
}
}

I added PXProcessing<ICSMCCustomersToDelete>.SetProcessed(); right after the DeleteCustomer method is called.  

Now, after the first record is processed, the counters are updated:

 

However, the remaining two records are both processed together and the Processed counter is not being updated the way it was for the first record.

After the remaining 2 records are processed, it goes straight to this:

 

In testing, if I force one of the records to fail to be deleted, this code will set a warning and the Warnings count will be updated.  In this line, there is a parameter to specify which record is being set to a warning. 
PXProcessing<ICSMCCustomersToDelete>.SetWarning(custList.IndexOf(cust), "Customer was unable to be deleted");

However, PXProcessing<ICSMCCustomersToMerge>.SetProcessed(); does not offer a parameter so I thought maybe that was the issue.

Any ideas on how to force the completed records to move to the Processed counter?

icon

Best answer by Leonardo Justiniano 6 October 2022, 21:28

View original

4 replies

Userlevel 6
Badge +4

Hi @joe21 

 

Can you set the current Item

PXProcessing<ICSMCCustomersToDelete>.SetCurrentItem(cust);

 

 

 

Userlevel 6
Badge +3

Hi @Leonardo Justiniano 

You are once again, a genius!

I did try something similar to that.  When I did that, it behaved like it did by default leaving all three in the processing counter until all three were processed. 

This was the original code and I remarked out that line because it made the second line not do anything at all.  When I posted the code above, I removed all my commented lines to keep it clean.  :-)

                    //default
                    //PXProcessing<ICSMCCustomersToMerge>.SetCurrentItem(custList.IndexOf(cust));
                    PXProcessing<ICSMCCustomersToMerge>.SetProcessed();
 

Your code is SLIGHTLY different than mine and YOURS WORKED!

My code used custList.IndexOf(cust) and your code did not have the IndexOf in it.

This makes me think I need to make the same adjustment to the other places where I used IndexOf.

Thank you so much for the quick solution!

 

EDIT:  I tried removing IndexOf from the SetWarning and SetError and it doesn’t like that.  I think maybe those two methods require the indexof.

 

Userlevel 6
Badge +4

Hi @joe21 

EDIT:  I tried removing IndexOf from the SetWarning and SetError and it doesn’t like that.  I think maybe those two methods require the indexof.

 

If you use Visual Studio you can clearly see the difference:

int index

 

object currentUtem

Cheers!

Userlevel 6
Badge +3

Hi @Leonardo Justiniano 

Yes sir.  I found that the IndexOf is required for the Warning and Error.  

Thank you for the insights.  Your suggestion worked and the application is running perfectly!

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 — 2024  Acumatica, Inc. All rights reserved