Stumped
Stumped

Reputation: 21

Enabling Fields on Sales Order Screen

I need to enable fields on the Sales Order screen when the Status of the Sales Order is Completed.

I found a few other posts with solutions on older versions of Acumatica where you need to also change things in the Automation steps but in Version 21.207 Automation steps has been replaced with Workflows and I can't seem to edit them for the Sales Order screen.

My Code:

protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
    var row = (SOOrder)e.Row;
    if (row == null) return;
    if (Condition1 != null && Condition2 == true)
    {     
        cache.AllowUpdate = true;
        Base.Document.Cache.AllowUpdate = true;
        PXUIFieldAttribute.SetEnabled<SOOrder.salesPersonID>(cache, e.Row, true);
    }
}

The Old Posts: Enable SOLine field after Order Completed How to enable CustomerOrderNbr field in Sales Order screen?

Update Tried the answer from Kyle Vanderstoep

But unfortunately the cache.AllowUpdate = true; stays False after stepping over it in debugging mode. Debugging

Update 2

The Solution from Kyle Vanderstoep did work in the end, after I remade the customization. Acumatica and my code was just acting up the first time round.

Upvotes: 0

Views: 161

Answers (1)

Kyle Vanderstoep
Kyle Vanderstoep

Reputation: 771

Two steps, override in workflow and in row selected. This one is for CustomerRefNbr

    public override void Configure(PXScreenConfiguration configuration)
    {
        var context = configuration.GetScreenConfigurationContext<SOOrderEntry, SOOrder>();
        context.UpdateScreenConfigurationFor(
            c => c.WithFlows(flowContainer =>
            {
                flowContainer
                    .Update(SOBehavior.SO, df => df
                        .WithFlowStates(fls =>
                        {
                            fls.Update<SOOrderStatus.completed>(flsc => flsc
                                .WithFieldStates(fs => fs.AddField<SOOrder.customerRefNbr>()));
                        }));
            }));
    }

    public virtual void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseN)
    {
        baseN(cache, e);
        SOOrder doc = e.Row as SOOrder;

        if (doc == null)
        {
            return;
        }
        cache.AllowUpdate = true;
        PXUIFieldAttribute.SetEnabled<SOOrder.customerRefNbr>(cache, null, true);
    }

Upvotes: 1

Related Questions