So when we save a Component, by default a major version is created with the "undefined" approval status. And with this approval status this Component can be published to any Publication Target irrespective of you set a minimum approval status for the Publication Target.
We want to stop this behavior, and assign a custom approval status when a Component is saved using Event System. We can update the approval status to "Unapproved" (out of the box) status using the below code on the Save Event of a Component, but not to a Custom Approval Status defined in Tridion.
private void OnSave(VersionedItem subject, SaveEventArgs e, EventPhases phase)
{
IWorkflowItem item = null;
if (subject is Component)
{
item = subject as Component;
}
if (item.ApprovalStatus != null && !item.ApprovalStatus.Title.Equals("undefined", StringComparison.InvariantCultureIgnoreCase))
{
e.ApprovalStatusResetOverride = ApprovalStatusType.Unapproved;
}
}
Question: Is there a way to assign a custom (Tridion defined) approval status, while saving a Component using Event System? (I don't want to start a workflow to update the approval status from Event System)