I have a need to bypass component workflow on the translated content. To achieve this i have planned to subscribe Save event at TransactionCommitted phase and then force finish the workflow activity.
I don't see i can able to capture this every time when i deploy dll with same code.
Note: We can't capture CheckInEvent in this case as component is getting into Tridion component workflow before that.
private void OnComponentSave(Component component, SaveEventArgs args, EventPhases phases)
{
try
{
//Please don't change the order of below condition as it is required to identify component has all properties loaded, and it is in workflow.
if (!component.LoadState.Equals(LoadState.NotLoaded) && component.LockType.HasFlag(LockType.InWorkflow) && component.CurrentActivity != null)
{
var currentActivity = component.CurrentActivity;
foreach (var performer in currentActivity.Performers)
{
if (WorkflowBypassingUsers.Contains(performer.Title.ToLower()))
{
var wfProcess = new ProcessInstance(currentActivity.Process.Id, component.Session);
ApprovalStatus status = new ApprovalStatus(new TcmUri(LiveApprovalStatusTcmUri), currentActivity.Process.Session);
_ = wfProcess.ForceFinish(status);
}
}
}
}
catch (Exception ex)
{
Logger.Write("[XXX.EventSystem.WorkflowBypasser.OnComponentSave]: ", "Exception Message:" + ex.Message, LoggingCategory.General);
throw new Exception(ex.Message);
}
}
Version: SDL Web 8.5