8

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)

1 Answer 1

6

Approval status is currently a read only property in the API and the only way it can be changed is via a workflow process (other than what you've currently done with your event system, which is limited to the built-in types of Undefined or Unapproved).

For one customer with a requirement similar to yours, I have implemented a simple, automated workflow which just assigns items a draft status and ends. It's not ideal (IMHO) and I'm not sure I'd recommend it to other customers but it does work.

I actually prefer your Event System, which does not require a workflow process to run and I would consider it as an enhancement for the customer I mention above, as an Unapproved status would work for them. Is there a reason that you really need a custom status?

5
  • Well, the "Unapproved" status causes the publishing to fail on all the publishing targets. Now for live publishing target, it serve the purpose and meet the requirement but this becomes a issue for staging publishing target. To approve some content for Live, user needs to see the content on staging first and for this we must run the content through a workflow, which gives the content "Staging" minimum approval status. And we don't want a separate workflow for staging. Commented Dec 16, 2016 at 9:57
  • Hmm... OK. Do you need a minimum approval status set on your staging target? I don't normally see that - usually I see them set to have no minimum status at all. Commented Dec 16, 2016 at 10:19
  • Even if you don't have a minimum approval status for staging, "Unapproved" content will fail. Right? Commented Dec 16, 2016 at 10:26
  • No, I just double checked this because I didn't realise at first that you had one set for your staging target. Unapproved components can be published to a target with no minimum approval status. Commented Dec 16, 2016 at 10:43
  • Hmmm... Thanks for the info David Commented Dec 16, 2016 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.