Created
February 28, 2022 15:32
-
-
Save BrianMRO/1e6e0eab73d100a70e7814b70114de96 to your computer and use it in GitHub Desktop.
Workflow - Basic Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using PX.Data; | |
using PX.Data.WorkflowAPI; | |
using PX.Objects.Common; | |
namespace Blog.CMMS | |
{ | |
using static PX.Data.WorkflowAPI.BoundedTo<CMMSWorkOrderEntry, CMMSWorkOrder>; | |
using static CMMSWorkOrder; | |
using State = Blog.CMMS.CMMSWorkOrder.Statuses; | |
public class CMMSWorkOrderEntry_Workflow : PXGraphExtension<CMMSWorkOrderEntry> | |
{ | |
public static bool IsActive() => | |
Common.FeatureInstalled<Common.CMMSFeaturesSet.main>(); | |
public override void Configure(PXScreenConfiguration config) | |
{ | |
Configure(config.GetScreenConfigurationContext<CMMSWorkOrderEntry, CMMSWorkOrder>()); | |
} | |
protected virtual void Configure(WorkflowContext<CMMSWorkOrderEntry, CMMSWorkOrder> context) | |
{ | |
context.AddScreenConfigurationFor(screen => | |
{ | |
screen | |
.StateIdentifierIs<status>() | |
.AddDefaultFlow(flow => | |
{ | |
return flow | |
.WithFlowStates(flowStates => | |
{ | |
// Add Initial State | |
flowStates.Add(State.InitialState, flowState => flowState.IsInitial(g => g.initializeState)); | |
// Add Normal States | |
flowStates.Add<State.hold>(); | |
flowStates.Add<State.open>(); | |
flowStates.Add<State.complete>(); | |
}) | |
.WithTransitions(transitions => | |
{ | |
transitions.AddGroupFrom(State.InitialState, ts => | |
{ | |
ts.Add(t => t | |
.To<State.hold>() | |
.IsTriggeredOn(g => g.initializeState) | |
); | |
}); | |
}); | |
}); | |
return screen; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment