1

I'm using Web 8.1 and trying to create a workflow in Visio 2016. My last activity of the workflow is an automatic activity which publishes the item and I'm using an External Activity with the code in the SDL demo page (Demo Code)

using System;
using Tridion.ContentManager.CoreService.Client;
using Tridion.ContentManager.CoreService.Workflow;

namespace ExternalAssemblyProperties
{
    public class MyClass : ExternalActivity
    {
        protected override void Execute()
        {
            PublishInstructionData publishInstruction = new PublishInstructionData();
            publishInstruction.ResolveInstruction = new ResolveInstructionData();
            publishInstruction.RenderInstruction = new RenderInstructionData();

            String[] itemsToPublish = new [] { "tcm:1-45" };
            String[] targets = new [] { "tcm:0-1-65537" };

            PublishTransactionData[] publishTransactions = CoreServiceClient.Publish(itemsToPublish, publishInstruction, targets, PublishPriority.Normal, null);
            ProcessInstance.Variables.Add("PublishTransaction", publishTransactions[0].Id);

            CoreServiceClient.FinishActivity(ActivityInstance.Id, new ActivityFinishData { Message = "Finished" }, null);
        }
    }
}

I'm getting this error:

Index was outside the bounds of the array.


Component: Tridion.ContentManager.Workflow
Errorcode: 0
User: NT AUTHORITY\SYSTEM

StackTrace Information Details:
   at ApprovalWorkflow.MyClass.Execute()
   at Tridion.ContentManager.CoreService.Workflow.ExternalActivity.ExecuteInternal(String activityInstanceId, String processInstanceXml, Action action)
   at Tridion.ContentManager.CoreService.Workflow.ExternalActivity.Tridion.ContentManager.Workflow.IExternalActivity.Execute(String activityInstanceId, String processInstanceXml)
   at Tridion.ContentManager.Workflow.ExternalActivityExecutor.ExecuteScript(String script, String currentActivityInstanceId, String processInstanceXml)
   at Tridion.ContentManager.Workflow.WorkflowAgentEngine.<>c__DisplayClass7.<ProcessActivity>b__1()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Tridion.ContentManager.Workflow.WorkflowAgentEngine.ProcessActivity(TcmUri activityInstanceId, Boolean isExpirationExecution)
   at Tridion.ContentManager.Workflow.Agent.QueueMessageHandler.HandleMessage()

Any idea what might be happening?

It's my understanding that item to publish can be the tcm of a component and target the tcmid of a target type, that's what I'm using.

Thanks in advance. Guillermo.

  • What happens if you use the GUI to publish that component to that target - are there any items in the "item to be published" list? – Neil Jul 27 '18 at 6:13
  • Are you using Topology Manager based publishing? Note that your publishing target is the TCM URI of a Publication Target rather than a Target Type. – Rick Pannekoek Jul 27 '18 at 7:02
  • Do you get a Warning in the Tridion Event Log? – Rick Pannekoek Jul 27 '18 at 7:02
  • Note that the reason that you get an (unclear) error is lack of robustness of your code. In general, there is no guarantee that the Publish method returns more than zero results (it all depends on system configuration). So, you should first test the number of results before trying to get the first. – Rick Pannekoek Jul 27 '18 at 7:49
  • 1
    That's because no transaction is created. Verify that you have a correct topology setup for the given target/publication, or that the item has reached the minimum approval status, etc. But most probably you are missing a mapping. – Atila Sos Jul 27 '18 at 14:55
1

Ok, there were 2 different problems.

  1. The component didn't have a Component Template associated to the schema of the component.
  2. I was trying to publish from the publication which is not allowed to publish.

Once I fixed number 1 and changed the publication to one where it's allowed. The publication happened.

Thanks for you answers! Best Regards. Guillermo.

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.