In automic how to communicate between the job in workflow? - automic

As we know that one job can call in multiple workflow.
I need an variable which give me the workflow name at time of runtime so that I can write this information in log.
It should not be global variable. it must be define with in the scope of workflow.

In the process tab - where I assume your code is and where you need the parent object (workflow in your case) - you can click on the "Variables..." menu item.
In the popped up variable picker you need to change to "Object" for "Category" and pick "Processor (name)".
This will provide the name of the superordinate (fancy word for parent) object - in your case the Workflow. Also available would be "Processor (RunID)" providing the ID.
This will insert the "system-variable" &$PROCESSOR#, which holds the name of the parent object or you simple copy that variable from my answer :)

Related

How do I add trusted code to a plone 4.x product that can be used by or as a workflow transition script?

I am trying to construct a workflow that can be assigned to arbitrary containers and will have the following behavior. When the container makes the transition from state A -> A', the contents of the container should be checked for their state and moved to a new state that depends on their present state. In other words:
obj1: in state 'a' would be transitioned to 'a*'
obj2: in state 'b' would be transitioned to 'b*'
and so on...
obj1 and obj2 are following the same workflow that branches to a number of final states (approved, denied, alternate, etc...)
I know how to do this, if I can trigger my python code as trusted code. Unfortunately, I have not been able to figure out how or where to put the code in my product so this will work. I have found references to using "external methods", however that seems to be going away. Also I want the code to reside in my project.
I think this is probably simple and I am overlooking something. Help with how to put this in my project or another route to achieving the same goal would be welcome.
The scripts support for DCWorkflow only supports through-the-web-addable objects, which limits you to External Methods there.
A better bet is to use workflow events instead. For each workflow transition, two events are fired:
Products.DCWorkflow.interfaces.IAfterTransitionEvent
Products.DCWorkflow.interfaces.IBeforeTransitionEvent
If you subscribe to either of those events, you can then filter on the correct workflow and transistion to react to transitions from trusted code.
Each event fired has the following attributes:
object: the workflowed object
workflow: the current applicable workflow object
old_state: a Products.DCWorkflow.States.StateDefinition object
new_state: another Products.DCWorkflow.States.StateDefinition object
transition: a Products.DCWorkflow.Transititions.TransitionDefinition object
status: a dictionary with the current workflow variables
kwargs: a dictionary of extra arguments passed in to the change-transition call.
Register a subscriber using ZCML:
<subscriber
provides="zope.component.testfiles.adapter.IS"
factory=".youreventsmodule.aftertransition_handler"
for="Products.DCWorkflow.interfaces.IAfterTransitionEvent"
/>
or, because the transition events are object events, listen only to the transition event if it applies to your objects:
<subscriber
provides="zope.component.testfiles.adapter.IS"
factory=".youreventsmodule.container_aftertransition_handler"
for=".interfaces.IMyContainerType
Products.DCWorkflow.interfaces.IAfterTransitionEvent"
/>
which registers your handler only for transition events on objects with the IMyContainerType interface only.
The handler would be:
def aftertransition_handler(event):
# handle all transition events, ever
or, when limiting it to one object interface:
def aftertransition_handler(obj, event):
# handle all transition events for our container interface

Extending CQ5 List component

I'm looking into extending the cq5 list component to create custom list displays (obviously). The constructor takes a SlingHttpServletRequest and the minimal java doc says "creates a list from the specified request".
Can someone explain how those request settings are used to build the list? what things in the request should I change to alter the list? Is there better documentation somewhere?
The component uses the request to retrieve the resource object.
In the init method it retrieves a the resource node's properties.
The "listFrom" property should matter for you the most as it controls how the list is created. Either by querybuilder, search, retrieving the children ("children") or tags.
The List component does a simple string equals to find out which option is set and executes the associated logic.
At the end a PageIterator is returned, which is processed by the jsp.

access class property in workflow foundation

so i am already invoking a workflow activity, with the "dataSet" containing an instance of my class Employee...
WorkflowInvoker.Invoke(wfManager.Activity, dataSet);
My Employee has a property called Department.
What i want is to edit a condition in my workflow xaml, but i am going to make it like this:
Employee.Department == "RND"
i am doing this in VS2012, and when i type Employee in the condition editor, i cannot access its properties. I just put my activity xaml file in the same project with my Employee class. What should i do more to access my class properties inside the activity xaml?
Basically you need to define an InArgument and map the external data to the arguments using a Dictionary. With that in place the object is available through the argument name.
See this blog post on how to pass data to an workflow.

How to assign a default value at runtime with Workflow Foundation WF4?

Using Windows Workflow Foundation WF4, I've got a custom activity with a System.Guid property called UniqueId.
I want the user to be able to drag my activity onto a workflow and have it automatically generate a new GUID value for UniqueId.
What's the easiest way to assign a new, read-only GUID value to this property at design time?
The trick is to use an IActivityTemplateFactory and in the Create() build the activity with default properties as you want it. Then you add the IActivityTemplateFactory instead of the activity itself to the toolbox.

Setting a dependency property's default value at design time in a Windows Workflow Foundation Custom Activity

I'm implementing a Custom Workflow and Activities to be reused in multiple projects and trying to get them to be as easy to use as possible. In this workflow I have a Property whose name is 'UserID' which I'd like to bind to a dependencyproperty in one of my activities. I can currently bind it at design time searching explicitly for the property each time I add one of these activities to the workflow, but I'd like for this activity to be binded automatically.
As far as i know (correct me if I'm wrong), to bind a dependency property at design time I need to specify a string of the form "Activity=NameOfWorkflow, Path=UserID" to the DefaultBindingProperty metadata tag, and I'd like the name of the workflow to be completed in some way. Any way of doing this?
Thanks
I finally managed to achieve this by attaching an ActivityToolboxItem to the Activity, and overriding a method in it that creates the instance shown in the designer. I used an ActivityBind object to bind the dependencyproperty to the workflow's property. To get the instance of the workflow, I just searched for an ancestor to my activity by calling act.Parent until the activity had no parent (and thus was the StateMachineWorkflowActivity itself)