Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I would like to initiate a workflow on a regular basis on specified time. This workflow has to execute a custom activity (business logic in C# code to create the components in Tridion) during its execution. Is it possible to achieve this in Tridion workflow? If not suggest the best way to achieve this?

share|improve this question

1 Answer 1

Starting a workflow should be done by some form of external trigger (typically a user creating or editing an item).

To do this in an automated way you would need to write a script/program which can be scheduled to trigger the process. I would consider writing either a windows service (probably overkill) or a power-shell type script (which can be scheduled to run when desired).

Your code should use the Core Service to start the workflow process for the given item. The following snippet may get you started:

StartWorkflowInstructionData startWorkflowInstruction = new StartWorkflowInstructionData();
startWorkflowInstruction.Assignee = new LinkToTrusteeData { IdRef = client.GetCurrentUser().Id };
startWorkflowInstruction.ActivityTitle = message;
startWorkflowInstruction.ProcessInstanceTitle = "ECL ITEM:" + actionType.ToString();
startWorkflowInstruction.Subjects = new[] { new LinkToIdentifiableObjectData { IdRef = bundle.Id } };
try
{
        client.StartWorkflow("tcm:0-" + pubID + "-1", startWorkflowInstruction, new ReadOptions());
    return usingItems.Count() + " items that are using " + itemID + " have been added to a bundle and are now in workflow";
}
catch(Exception e)
{
    return e.Message;
}

This sample adds items to a bundle and starts the workflow (the concept is similar if you are not using bundles). Be careful to check if the item you want to put into workflow is not already in workflow or it will fail.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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