1

In Tridion 2011 SP1, I have the following code on a OnComponentCheckedInPost method in my EventSystem:

// finish process if tcm item is the same and version is 0
bool newItem = false;
foreach (XmlElement process in processes.ChildNodes)
{
    var tcmUri = process.Attributes["TCMItem"].Value + "-v0";
    if (tcmUri == item.Id)
    {
        ProcessInstance wfProcess = session.GetObject(process.Attributes["ID"].Value) as ProcessInstance;
        ApprovalStatus status = new ApprovalStatus(session);
        var finishedProcess = wfProcess.ForceFinish(status);
        newItem = true;
        break;
    }
}

// Edit item and put back into WF
if (newItem)
{
    var compUri = item.Id.ToString().Replace("-v0", "");
    var comp = session.GetObject(compUri) as Component;
    comp.CheckOut(false);
    comp.Title = item.Title + " ";
    comp.Save(true);
 }

I'm using this code to check if a component is in Workflow (v0.xxx) and switch the version to v1.0 so that the component is available and thus can be added to a page.

The code works great if I create components as a Tridion system administrator. However, when I run it as a regular non-admin user (member of Editors group), this line var finishedProcess = wfProcess.ForceFinish(status); throws the following error on the event log:

You do not have permission to perform this action.

Component: Tridion.EventSystem

Errorcode: 0

User: MyDomain\MTSUser

StackTrace Information Details: at Tridion.ContentManager.Workflow.WorkflowObject.AssertWorkflowManagementRightsOnContextRepository() at Tridion.ContentManager.Workflow.ProcessInstance.OnFinishing(FinishProcessEventArgs eventArgs) at Tridion.ContentManager.Workflow.ProcessInstance.Finish(ProcessFinishReason reason, ApprovalStatus approvalStatus) at Tridion.ContentManager.Workflow.ProcessInstance.ForceFinish(ApprovalStatus approvalStatus) at Tridion.EventSystem.Utilities.FinishWfActivity(Session session, Component item) at Tridion.EventSystem.Tridion.EventSystem.EventHandlers.OnComponentCheckedInPost(Component component, CheckInEventArgs args, EventPhases phase)

Is the MTSUser account not an administrator already? I've tried adding this account as an impersonation user in the Content Manager configuration as well as a system administrator user in CME but no luck.

Why is it failing? Any ideas or suggestions?

  • Maybe we need to impersonate the admin user? – robrtc May 21 '14 at 17:01
  • The error indicates that the user is the MTS User - or at least an MTS User account on a fictitious domain. So check that the account is the one you think it is, and then verify whether or not it's an administrator. You'll get the answer much quicker by examining your system than by asking here. :-) – Dominic Cronin May 21 '14 at 20:56
  • Yes, it is indeed the real MTS User. I just replaced my real domain with dummy text "MyDomain" for the purposes of this post. I guess I don't fully understand the purpose & permission level of this account. I would have expected MTS User to have full admin access to everything without the need for impersonation at the code level. – Haniel Pulido Jr May 22 '14 at 13:06
1

I think your user must have write permission and Workflow management rights.

  • Yes, adding Workflow management rights does work, but I'm concerned about giving this right to a regular Author or Editor. These users shouldn't have the ability to finish a WF process and thereby bypass the approval process. – Haniel Pulido Jr May 21 '14 at 17:58
  • 1
    After further investigation, impersonating the MTSUser will also work but that involves creating a new session, not to mention consuming more resources - great discussion on this topic here: stackoverflow.com/questions/10400989/…. Therefore, it looks like adding Workflow management rights is the safer way to go. – Haniel Pulido Jr May 21 '14 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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