To make Shipment fields enabled in status Confirmed I had to add two overrides:
Override in graph RowSelected event
Update workflow step
I.e. I guess Acumatica starts from applying logic of the Base graph, then applies logic of the Graph Extension, then logic of the Base workflow, and then logic of the Workflow Extension.
Also found useful page describing how field states are
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.Serialization;
using System.Text;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.WorkflowAPI;
using PX.Common;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.SM;
using PX.Objects.IN.Overrides.INDocumentRelease;
using POLineType = PX.Objects.PO.POLineType;
using POReceiptLine = PX.Objects.PO.POReceiptLine;
using PX.CarrierService;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.SO.Services;
using PX.Objects.PO;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Common.Collection;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.SO.GraphExtensions.SOShipmentEntryExt;
using PX.Api;
using LocationStatus = PX.Objects.IN.Overrides.INDocumentRelease.LocationStatus;
using ShipmentActions = PX.Objects.SO.SOShipmentEntryActionsAttribute;
using PdfSharp.Pdf.IO;
using PX.Objects.IN.Attributes;
using PX.Objects;
using PX.Objects.SO;
namespace PX.Objects.SO
{
usingstatic BoundedTo<SOShipmentEntry, SOShipment>;
using State = SOShipmentStatus;
publicclass SOShipmentEntry_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>
{
#region Event HandlersprotectedvirtualvoidSOShipment_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
SOShipment row = e.Row as SOShipment;
if (row != null)
{
if (row.Status == SOShipmentStatus.Confirmed)
{
Base.Document.Cache.AllowUpdate = true;
PXUIFieldAttribute.SetEnabled<SOShipment.shipVia>(cache, row, true);
PXUIFieldAttribute.SetEnabled<SOShipment.siteID>(cache, row, true);
PXUIFieldAttribute.SetEnabled<SOShipment.curyFreightCost>(cache, row, true);
}
}
}
#endregion Event Handlers
}
#region Workflow Customizationpublicclass SOShipmentEntry_ExtWorkflow : PXGraphExtension<SOShipmentEntry_Workflow, SOShipmentEntry>
{
publicstaticboolIsActive() => true;
publicoverridevoidConfigure(PXScreenConfiguration config)
{
ConfigureNewWorkflow(config.GetScreenConfigurationContext<SOShipmentEntry, SOShipment>());
}
protectedvirtualvoidConfigureNewWorkflow(WorkflowContext<SOShipmentEntry, SOShipment> context)
{
Condition Bql<T>() where T : IBqlUnary, new() => context.Conditions.FromBql<T>();
var conditions = new
{
ShipmentIsInConfirmedStatus = Bql<Where<SOShipment.status, Equal<SOShipmentStatus.confirmed>>>()
}.AutoNameConditions();
context.UpdateScreenConfigurationFor(screen =>
{
return screen
.WithActions(actions =>
{
actions.Update(
action => action.correctShipmentAction, (ActionDefinition.ConfiguratorAction actionConfiguration) =>
actionConfiguration.IsDisabledWhen(conditions.ShipmentIsInConfirmedStatus));
})
.UpdateDefaultFlow(flow =>
{
return flow
.WithFlowStates(states =>
states.Update<SOShipmentStatus.confirmed>(flowState =>
flowState
.WithFieldStates(containerAdjuster => {
containerAdjuster.AddField<SOShipment.shipVia>();
containerAdjuster.AddField<SOShipment.siteID>();
containerAdjuster.AddField<SOShipment.curyFreightCost>();
})
));
});
});
}
}
#endregion Workflow Customization
}
@abaranovhs Have you tried using the workflow functionality in a customization package? I have enabled fields that would typically be locked down through this method before. The other alternative would be following something like this where it is always enabled, then using workflow to better control when it is enabled based on status:
Here’s I’m providing screenshot of the SalesDemo Acumatica showing shipment in status Confirmed and the customization with your suggested code applied.
My understanding is that at least in Acumatica 22R2 which I am on, it is no longer enough to have this in RowSelected event.
I also need to override default workflow via code or via customization project editor to manage state of the fields.
I want to do this via code, so this was the question - how do I write this code properly. I could not find an good example explaining how to override existing workflow and make field editable in a certain status in T270_WorkflowAPI documentation.
To make Shipment fields enabled in status Confirmed I had to add two overrides:
Override in graph RowSelected event
Update workflow step
I.e. I guess Acumatica starts from applying logic of the Base graph, then applies logic of the Graph Extension, then logic of the Base workflow, and then logic of the Workflow Extension.
Also found useful page describing how field states are
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.Serialization;
using System.Text;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Data.WorkflowAPI;
using PX.Common;
using PX.Objects.AR;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.SM;
using PX.Objects.IN.Overrides.INDocumentRelease;
using POLineType = PX.Objects.PO.POLineType;
using POReceiptLine = PX.Objects.PO.POReceiptLine;
using PX.CarrierService;
using PX.Data.DependencyInjection;
using PX.LicensePolicy;
using PX.Objects.SO.Services;
using PX.Objects.PO;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Common.Collection;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.SO.GraphExtensions.SOShipmentEntryExt;
using PX.Api;
using LocationStatus = PX.Objects.IN.Overrides.INDocumentRelease.LocationStatus;
using ShipmentActions = PX.Objects.SO.SOShipmentEntryActionsAttribute;
using PdfSharp.Pdf.IO;
using PX.Objects.IN.Attributes;
using PX.Objects;
using PX.Objects.SO;
namespace PX.Objects.SO
{
usingstatic BoundedTo<SOShipmentEntry, SOShipment>;
using State = SOShipmentStatus;
publicclass SOShipmentEntry_Extension : PXGraphExtension<PX.Objects.SO.SOShipmentEntry>
{
#region Event HandlersprotectedvirtualvoidSOShipment_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
SOShipment row = e.Row as SOShipment;
if (row != null)
{
if (row.Status == SOShipmentStatus.Confirmed)
{
Base.Document.Cache.AllowUpdate = true;
PXUIFieldAttribute.SetEnabled<SOShipment.shipVia>(cache, row, true);
PXUIFieldAttribute.SetEnabled<SOShipment.siteID>(cache, row, true);
PXUIFieldAttribute.SetEnabled<SOShipment.curyFreightCost>(cache, row, true);
}
}
}
#endregion Event Handlers
}
#region Workflow Customizationpublicclass SOShipmentEntry_ExtWorkflow : PXGraphExtension<SOShipmentEntry_Workflow, SOShipmentEntry>
{
publicstaticboolIsActive() => true;
publicoverridevoidConfigure(PXScreenConfiguration config)
{
ConfigureNewWorkflow(config.GetScreenConfigurationContext<SOShipmentEntry, SOShipment>());
}
protectedvirtualvoidConfigureNewWorkflow(WorkflowContext<SOShipmentEntry, SOShipment> context)
{
Condition Bql<T>() where T : IBqlUnary, new() => context.Conditions.FromBql<T>();
var conditions = new
{
ShipmentIsInConfirmedStatus = Bql<Where<SOShipment.status, Equal<SOShipmentStatus.confirmed>>>()
}.AutoNameConditions();
context.UpdateScreenConfigurationFor(screen =>
{
return screen
.WithActions(actions =>
{
actions.Update(
action => action.correctShipmentAction, (ActionDefinition.ConfiguratorAction actionConfiguration) =>
actionConfiguration.IsDisabledWhen(conditions.ShipmentIsInConfirmedStatus));
})
.UpdateDefaultFlow(flow =>
{
return flow
.WithFlowStates(states =>
states.Update<SOShipmentStatus.confirmed>(flowState =>
flowState
.WithFieldStates(containerAdjuster => {
containerAdjuster.AddField<SOShipment.shipVia>();
containerAdjuster.AddField<SOShipment.siteID>();
containerAdjuster.AddField<SOShipment.curyFreightCost>();
})
));
});
});
}
}
#endregion Workflow Customization
}
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.