cancel
Showing results for 
Search instead for 
Did you mean: 

rules & workflows on the content of the document

notherien
Champ in-the-making
Champ in-the-making
HI;

how we can execute a workflow or rules on a file based on the text (content) of this document?

thx 4 ur F1 Smiley Very Happy
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
Here are a couple of options. There may be others…

There isn't an OOTB rule condition that looks in the content to decide whether or not to apply a rule. So, option 1 is you could write your own condition handler that does. If you look at web-client-config.xml you'll see where Alfresco keeps track of its OOTB condition handlers and their associated Java classes:

<condition-handlers>
         <handler name="compare-mime-type" class="org.alfresco.web.bean.rules.handlers.CompareMimeTypeHandler" />
         <handler name="compare-property-value" class="org.alfresco.web.bean.rules.handlers.PropertyValueHandler" />
         <handler name="has-aspect" class="org.alfresco.web.bean.rules.handlers.HasAspectHandler" />
         <handler name="in-category" class="org.alfresco.web.bean.rules.handlers.InCategoryHandler" />
         <handler name="is-subtype" class="org.alfresco.web.bean.rules.handlers.IsSubTypeHandler" />
         <handler name="composite-condition" class="org.alfresco.web.bean.rules.handlers.CompositeConditionHandler" />
         <handler name="compare-date-property" class="org.alfresco.web.bean.rules.handlers.property.DatePropertyValueConditionHandler" />
         <handler name="compare-integer-property" class="org.alfresco.web.bean.rules.handlers.property.IntegerPropertyValueConditionHandler" />
         <handler name="compare-text-property" class="org.alfresco.web.bean.rules.handlers.property.TextPropertyValueConditionHandler" />
</condition-handlers>

You can use one of those classes as an example, write your own handler, then extend Alfresco's config to add yours to the list. Then set up your rule to use your new condition and have that rule do whatever action you need (start a workflow, run some action, execute a script, or whatever).

Option 2 is you can configure a rule to launch an advanced workflow (you do this by using the Execute Script action and point to server-side JavaScript that launches the desired workflow) and then have the first step in the workflow use JavaScript or Java to check the content and then proceed through the workflow appropriately based on what's there.

Some things (there are probably more) to think about when deciding between the two:
- Rule conditions get fired when anything is added to the folder, regardless of the client that put them there. This means that class better execute fast or your performance across the entire platform will suffer when adding docs to the repo. If you've got inefficient code or large bodies of content to inspect, avoid the condition handler option.
- Rule condition would be a more flexible/configurable route because your condition handler could let the person creating the rule specify what's being searched for. So if you need to do this in a lot of different folders with different search patterns, and you want end users to be able to config, you might like the condition handler approach.
- The workflow route is good if you are almost always going to be kicking off a workflow anyway. It's tougher to configure though, and if you are adding a lot of content, you're going to be generating a lot of workflows, potentially unnecessarily.

Hope that helps,

Jeff

notherien
Champ in-the-making
Champ in-the-making
thanks  jpotts for the reply,me what I seek is how I can run a workflow X1 on delivery with the total exceeds 100$ and a workflow X2 on the delivery of which the total is between 50$ and 100 $…for exemple

jpotts
World-Class Innovator
World-Class Innovator
Use two process nodes and a decision. So you'd have a decision node that would inspect the total on the metadata of the object in the workflow. You can get to that easily from the bpm_package.children object. The decision node would choose between two transitions depending on the value. If transition_X1 is taken, it leads to a process node that runs your X1 workflow. (A process node is a node that runs another deployed workflow as a sub-process). If transition_X1 is taken, it leads to a process node that runs your X2 workflow.

Jeff

notherien
Champ in-the-making
Champ in-the-making
Hi;
thank you, this is a very good idea, but my problem is that the total does not is a metadata but it is in a table in the delivery

best regards
notherien

jpotts
World-Class Innovator
World-Class Innovator
Ah, it sounds like the data you care making your decision on is embedded in the document. If those documents are in a standard format, maybe you can use a metadata extracter to grab the data out of the document and put it in a property. If the documents aren't in a standard format, parsing them might get difficult/expensive.

If you don't want to extract the metadata, you can just parse the value from within the jBPM decision node. Decisions can be implemented with Java code so that means decisions can be made based on anything you can do with Java, whether that's parse a complex binary file format, make calls to external systems, etc.

Jeff