Skip to main content
Question

Cannot be show Processing dialog (PxProcessing dialog) for the newly created button on page Process Order

  • October 21, 2024
  • 2 replies
  • 48 views

I have created a “Process Blanket Lines” Button on the Process Order page


I want to click the “Process Blanket Lines” button to display the Show Processing Dialog 
like so:

 

to monitor code behavior in function GenerateNewLineItems. However when I click Process Blank Lines it still doesn't show the Processing Dialog.

Here is my code:

 

using System;
using System.Collections;
using System.Collections.Generic;
using PX.Data;
using PX.Objects.CN.Subcontracts.AP.CacheExtensions;
using PX.Objects.SO;

public class SOCreateShipment_Extension : PXGraphExtension<PX.Objects.SO.SOCreateShipment>
{

    public PXAction<SOOrderFilter> processCustomization;
    [PXProcessButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Process Blanket Lines", Visible = true)]
    protected virtual IEnumerable ProcessCustomization(PXAdapter adapter)
    {
        SOOrderFilter filter = Base.Filter.Current as SOOrderFilter;
        if (filter != null && filter.Action == "SO301000$addBlanketLine")
        {
            List<SOOrder> ordersToProcess = new List<SOOrder>();

            foreach (SOOrder order in Base.Caches[typeof(SOOrder)].Updated)
            {
                if (order.Selected == true)
                {
                    ordersToProcess.Add(order);
                }
            }

            foreach (SOOrder order in ordersToProcess)
            {
                ProcessOrder(order); 
            }

            return adapter.Get();
        }

        return adapter.Get();
    }

    private void ProcessOrder(SOOrder order)
    {
        try
        {
            PXProcessing<SOOrder>.SetCurrentItem(order);
            var filePath = PXCache<SOOrderFilter>.GetExtension<SOOrderFilterExt>(Base.Filter.Current)?.UsrNextSchShipDate;

            if (filePath != null)
            {
                GenerateNewLineItems(order, filePath);
                PXProcessing<SOOrder>.SetProcessed(); 
            }
            else
            {
                PXProcessing<SOOrder>.SetWarning("There is no Next Sch Ship Date yet"); 
            }
        }
        catch (Exception ex)
        {
            PXProcessing<SOOrder>.SetError(ex); 
        }
    }

    private void GenerateNewLineItems(SOOrder parentOrder, DateTime? nextSchShipDate)
    {
        PXTrace.WriteInformation("Generating new line items...");
        using (PXTransactionScope ts = new PXTransactionScope())
        {
            SOOrderEntry orderEntryGraph = PXGraph.CreateInstance<SOOrderEntry>();
            // logic customization
            orderEntryGraph.Save.Press();
            ts.Complete();
        }
    }
}


I used:
PXProcessing<SOOrder>.SetProcessed();
PXProcessing<SOOrder>.SetWarning();
PXProcessing<SOOrder>.SetError();

However it still doesn't show the Processing Dialog


Please help me see which part of my code is missing or incorrect?

2 replies

darylbowman
Captain II
Forum|alt.badge.img+13

I saw your other post, and I understand you’d like to use a processing dialog. I must admit, I’ve never done it, but I have some notes about for when I have a need for it:

To require a confirmation message:

  • Lines.SetParametersDelegate(AllowProcessing);
  • public bool AllowProcessing(List<Record> records)
    {
        // You can make this check optional
    	if (Filter.Current.ActionID != Actions.ApplyPrepayment)
    	    return true;
    
    	return ProcessingView.Ask(Constants.Title, Constants.Body, MessageButtons.YesNo).IsPositive();
    }

It seems like you could override RowSelected and set the parameters delegate for the whole screen. Then use the optional check to return true for all screens except yours.

This feels more best-practice and robust than what you’re trying, but maybe I’m not understanding what you’re after.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2755 replies
  • December 24, 2024

Hi ​@PhatPham were you able to find a solution? Thank you!


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