Skip to main content

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

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


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


Reply