Workflow States: Tracking Changes in States

The MYOB Acumatica Framework automatically tracks the state changes whenever a transition moves a record from one state to another in a workflow. This provides you with the ability to audit the state changes. To enable this functionality, you must declare the following fields in the underlying DAC of the workflow:

  • A field of the Guid type that is declared with the PXDBStateChangedByID attribute
  • A field of the string type that is declared with thePXDBStateChangedByScreenID attribute
  • A field of the DateTime type that is declared with the PXDBStateChangedDateTime attribute
These fields are updated whenever a workflow transition happens and the workflow state is changed. These fields store the ID of the user who made the last workflow transition for the data record, the screen ID of the application screen on which the last workflow transition occurred for the data record, and the date and time in UTC of the data record's last workflow transition. The following code shows how to declare these fields in a DAC.
[PXDBStateChangedByID()]
public virtual Guid? StateChangedByID { get; set; }

[PXDBStateChangedByScreenID()]
public virtual string StateChangedByScreenID { get; set; }

[PXDBStateChangedDateTime]
public virtual DateTime? StateChangedDateTime { get; set; }