2

I want to start the workflow if the version of the Component is higher than 1.0. I have tried to achieve it by adding automatic decision activity. But I cant add it as a first activity of workflow.

Please suggest, if there are any way to handle this situation ? (FYI: I am using Tridion 2013 SP1)

  • Remember that when the child component is sent for translation it's checked out. If you're not managing this via workflow (e.g. suspending the parent item in workflow so it can't be updated), what will you do with updates to the parent component whilst the child item is being translated ... otherwise the translation will soon be out of synch. – Dylan .. Mark Saunders Mar 8 '16 at 0:27
5

Use OnComponentSavePost Event to check the moment when component entered the workflow.

...
public Constructor()
 {
 EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePost, EventPhases.TransactionCommitted);   
 }
...

Not all components are connected to a workflow. If the workflow process attribute is set to tcm:0:0:0 that means component is not connected to any workflow and the code shouldn't execute. You can find the workflow process attribute in components xml. Because only manual activity can be entered first in the workflow put some dummy manual activity with characteristic name so you can identify it in the code, again not all manual activities should enter you code only the one you created for this. Use something like this:

private void OnComponentSavePost(Component component, SaveEventArgs args, EventPhases phases)
{
String activityInstanceId = String.Empty;
XmlElement xmlElement = component.ToXml();
XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
xmlNamespaceManager.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
activityInstanceId = xmlElement.SelectSingleNode("//*[local-name()='ActivityInstance']", xmlNamespaceManager).Attributes["xlink:href"].Value;

if (!activityInstanceId.Equals("tcm:0-0-0"))
   {
     ActivityInstance activityInstance = new ActivityInstance(new TcmUri(activityInstanceId), component.Session);
     if (activityInstance.Position == 1 && activityInstance.Title.Contains("SOMETHING CHARACTERISTIC IN FIRST MANUAL ACTIVITY NAME"))
         {
           //enter code here
         }
    }
}

P.S. Tridion 2013SP1 allows using first automatic activity only for Bundles. There is a patch in HR1 that enables this.

| improve this answer | |
  • Thanks for the information. But I want to start the workflow only if the version of that component is greater than or equal to 1.0(Major version). – Sayantan Basu Mar 8 '16 at 9:04
  • 1
    Every component that has a schema that is connected to a workflow will enter the workflow by default. Meaning you need to make branches in your workflow diagram to achieve your requirement. In the diagram you will have first dummy manual activity as I explained above that will have two branches. One branch will exit the workflow under the condition you want and other branch will follow the workflow. This startup branching must be done in event system using the code I just wrote. – Ognjen Ivetic Mar 8 '16 at 9:38
2

You can handle this via the SDL Tridion Events System. Below is a link to Workflow and Event System classes and namespaces in the SDL documentation

http://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-B12C3981-CC52-4CAD-87B5-800185541480

| improve this answer | |

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.