cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table and Templates

messmeister
Champ in-the-making
Champ in-the-making
Hello,

i have a question about the "Generate Document Task" in Alfresco Activiti Suite 1.4:
is there any info on how to list entries of a dynamic table with a MS Word template? <<[myTable]>> is printing the contents of the table as a json string and i cannot use <<foreach [in myTable]>> to iterate of the table entries.
The dynamic table was created with the default Form Editor.


Thank you for any information on this!
9 REPLIES 9

messmeister
Champ in-the-making
Champ in-the-making
It seems i cannot use the LINQ expressions in this forum because it get's escaped with < >.
I wanted to say that i cannot use the foreach expression with the dynamic table.

jbarrez
Star Contributor
Star Contributor
Hmm, i think you will need to do some pre-processing on the dynamic table json before it's passed into the template:

see https://docs.alfresco.com/activiti/docs/dev-guide/1.4.0/#templateVariableProcessor
(it's a bit crude, as it's applicable to all templates, but it'll get the job done. We will add a more refined mechanism in the future)

messmeister
Champ in-the-making
Champ in-the-making
Thank you very much for the info! Do I have to invoke my custom processor in the template? Because if I follow the example in the developer guide as you mentioned, nothing happens.

jbarrez
Star Contributor
Star Contributor
You have to put a class implementing that interface on the classpath. Make sure it's
1) in the right package (com.activiti.extension.bean)
2) has @Component on it

If you had that already … please share your code here

messmeister
Champ in-the-making
Champ in-the-making
Hi, i've double checked and yes, it is the correct package and it has the @Component annotation.
<java>
package com.activiti.extension.bean;

import com.activiti.api.docgen.TemplateVariableProcessor;
import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;

import org.apache.log4j.Logger;


@Component
public class CustomTemplateProcessor implements TemplateVariableProcessor {

    private static final Logger logger = Logger.getLogger(CustomTemplateProcessor.class);
    public Object process(DelegateExecution execution, String variableName, Object value) {

        logger.info("processing….");
        return value.toString() + "___" + "HELLO_WORLD";
    }
}

</java>

It's not doing anything at all.
FYI: I have other beans in the same package to use as script task expressions and they are working just fine…
Any idea??

Thank you very much!

jbarrez
Star Contributor
Star Contributor
Hmm that looks allright. I tested it a few weeks ago and it worked. I'll recheck tomorrow and post back here.

messmeister
Champ in-the-making
Champ in-the-making
Thank you very much! I'm looking forward to your response.

balsarori
Champ on-the-rise
Champ on-the-rise
@messmeister

For a custom TemplateVariableProcessor to be called the variable should be in the following format in the template
<<[variables.get("varName")]>>

rachana
Champ in-the-making
Champ in-the-making

Hi Team,

I have a same requirement.

Could you please tell how you implement it.What we need to process in Custom Template Processor.

Thanks

Rachana Garg