Skip to main content
Solved

Overriding Sales Order status 'Shipping' Field Availability

  • October 10, 2024
  • 2 replies
  • 47 views

Forum|alt.badge.img+8
  • Captain II
  • 366 replies

Hello everyone,

 

I am looking to change the UI availability for the editing of fields when a Sales Order is in shipping.

I have moved the Credit Hold stage to the Shipment stage because of how our business processes work, we process and manufacture Sales Orders but do not ship until the leadership team is satisfied with payments.

 

I am aware that I can make the fields editable through a RowSelected handler, however, would it be better to override the DisableWholeScreen method which is used in the SO workflow to make these fields editable.

Another condition that needs to be satisfied is that the Qty on Shipments field cannot be higher than 0, for the fields to be editable, I am not sure if I can put a condition into a workflow .WithFieldAssignments method.

 

Could someone advise on what the best way to go forward with this would be.

 

Thanks,

Aleks

Best answer by aiwan

Hello everyone,

 

Thanks to @Keith Richardson @Samvel Petrosov and some others. 

I removed the shipment flow state from the SO workflow with the Workflow API and added it back with an amended method to disable fields.

Original method:

public static void DisableWholeScreen(FieldState.IContainerFillerFields states)
        {
            states.AddTable<SOOrder>(state => state.IsDisabled());
            states.AddTable<SOLine>(state => state.IsDisabled());
            states.AddTable<SOTaxTran>(state => state.IsDisabled());
            states.AddTable<SOBillingAddress>(state => state.IsDisabled());
            states.AddTable<SOBillingContact>(state => state.IsDisabled());
            states.AddTable<SOShippingAddress>(state => state.IsDisabled());
            states.AddTable<SOShippingContact>(state => state.IsDisabled());
            states.AddTable<SOLineSplit>(state => state.IsDisabled());
            states.AddTable<CRRelation>(state => state.IsDisabled());
        }

My method:

public static void EnableSOLine(FieldState.IContainerFillerFields states)
{
    states.AddTable<SOOrder>(state => state.IsDisabled());
    states.AddTable<SOTaxTran>(state => state.IsDisabled());
    states.AddTable<SOBillingAddress>(state => state.IsDisabled());
    states.AddTable<SOBillingContact>(state => state.IsDisabled());
    states.AddTable<SOShippingAddress>(state => state.IsDisabled());
    states.AddTable<SOShippingContact>(state => state.IsDisabled());
    states.AddTable<CRRelation>(state => state.IsDisabled());
}

Below is what I did to remove and then add back the shipment stage to the SO workflow:

public sealed override void Configure(PXScreenConfiguration config)
{
    Configure(config.GetScreenConfigurationContext<SOOrderEntry,
    SOOrder>());
}

protected static void Configure(WorkflowContext<SOOrderEntry,
    SOOrder> context)
{
    context.UpdateScreenConfigurationFor(screen => screen
        .WithFlows(flows =>
        {
            flows.Update<SOBehavior.sO>(flow => flow
            .WithFlowStates(flowStates =>
            {
                flowStates.Remove<State.shipping>();
                flowStates.Add<State.shipping>(flowState =>
                {
                    return flowState
                        .WithActions(actions =>
                        {
                            actions.Add(g => g.createShipmentIssue);
                            actions.Add(g => g.emailSalesOrder);
                            actions.Add(g => g.createPurchaseOrder);
                            actions.Add<CreatePaymentExt>(e => e.createAndCapturePayment);
                            actions.Add<CreatePaymentExt>(e => e.createAndAuthorizePayment);
                        })
                        .WithEventHandlers(handlers =>
                        {
                            handlers.Add(g => g.OnShipmentUnlinked);
                            handlers.Add(g => g.OnShipmentConfirmed);
                        })
                        .WithFieldStates(EnableSOLine);
                });
            }));
        })); 
}

Hope this helps someone in the future!

Aleks

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

2 replies

Forum|alt.badge.img+8
  • Author
  • Captain II
  • 366 replies
  • Answer
  • October 15, 2024

Hello everyone,

 

Thanks to @Keith Richardson @Samvel Petrosov and some others. 

I removed the shipment flow state from the SO workflow with the Workflow API and added it back with an amended method to disable fields.

Original method:

public static void DisableWholeScreen(FieldState.IContainerFillerFields states)
        {
            states.AddTable<SOOrder>(state => state.IsDisabled());
            states.AddTable<SOLine>(state => state.IsDisabled());
            states.AddTable<SOTaxTran>(state => state.IsDisabled());
            states.AddTable<SOBillingAddress>(state => state.IsDisabled());
            states.AddTable<SOBillingContact>(state => state.IsDisabled());
            states.AddTable<SOShippingAddress>(state => state.IsDisabled());
            states.AddTable<SOShippingContact>(state => state.IsDisabled());
            states.AddTable<SOLineSplit>(state => state.IsDisabled());
            states.AddTable<CRRelation>(state => state.IsDisabled());
        }

My method:

public static void EnableSOLine(FieldState.IContainerFillerFields states)
{
    states.AddTable<SOOrder>(state => state.IsDisabled());
    states.AddTable<SOTaxTran>(state => state.IsDisabled());
    states.AddTable<SOBillingAddress>(state => state.IsDisabled());
    states.AddTable<SOBillingContact>(state => state.IsDisabled());
    states.AddTable<SOShippingAddress>(state => state.IsDisabled());
    states.AddTable<SOShippingContact>(state => state.IsDisabled());
    states.AddTable<CRRelation>(state => state.IsDisabled());
}

Below is what I did to remove and then add back the shipment stage to the SO workflow:

public sealed override void Configure(PXScreenConfiguration config)
{
    Configure(config.GetScreenConfigurationContext<SOOrderEntry,
    SOOrder>());
}

protected static void Configure(WorkflowContext<SOOrderEntry,
    SOOrder> context)
{
    context.UpdateScreenConfigurationFor(screen => screen
        .WithFlows(flows =>
        {
            flows.Update<SOBehavior.sO>(flow => flow
            .WithFlowStates(flowStates =>
            {
                flowStates.Remove<State.shipping>();
                flowStates.Add<State.shipping>(flowState =>
                {
                    return flowState
                        .WithActions(actions =>
                        {
                            actions.Add(g => g.createShipmentIssue);
                            actions.Add(g => g.emailSalesOrder);
                            actions.Add(g => g.createPurchaseOrder);
                            actions.Add<CreatePaymentExt>(e => e.createAndCapturePayment);
                            actions.Add<CreatePaymentExt>(e => e.createAndAuthorizePayment);
                        })
                        .WithEventHandlers(handlers =>
                        {
                            handlers.Add(g => g.OnShipmentUnlinked);
                            handlers.Add(g => g.OnShipmentConfirmed);
                        })
                        .WithFieldStates(EnableSOLine);
                });
            }));
        })); 
}

Hope this helps someone in the future!

Aleks


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2751 replies
  • October 15, 2024

Thank you for sharing your solution with the community @aiwan!


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