1 2 Previous Next 20 Replies Latest reply on Jul 31, 2009 11:33 AM by kukeltje

    [jBPM 4] Mai templates context variables

    gleenders

      In jBPM 3 it was possible to use some context variables in EL (for ex. taskInstance & processInstance).
      It seems to be that this doesn't work in jBPM4?

      Gert

        • 1. Re: [jBPM 4] Mai templates context variables
          tejjbpm

          I dont see why it should not..how r u accessing the variables? Could you explain with some example?

          • 2. Re: [jBPM 4] Mail templates context variables
            gleenders

            Template:

            <?xml version="1.0" encoding="UTF-8"?>
            
            <jbpm-configuration>
            
             <process-engine-context>
            
             <mail-template name="task-notification">
             <to addresses="xxxxxxxx@xxxxx.be" />
             <subject>Assignment notification</subject>
             <text>Task #{taskInstance.name} is assigned</text>
             </mail-template>
            
             </process-engine-context>
            
            </jbpm-configuration>
            


            Stacktrace:

            INFO: exception while executing command org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd@5b52f1
            org.jbpm.api.JbpmException: script evaluation error: javax.el.PropertyNotFoundException: Cannot find property taskInstance
             at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:118)
             at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:106)
             at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:78)
             at org.jbpm.pvm.internal.email.impl.MailProducerImpl.evaluateExpression(MailProducerImpl.java:137)
             at org.jbpm.pvm.internal.email.impl.MailProducerImpl.fillContent(MailProducerImpl.java:301)
             at org.jbpm.pvm.internal.email.impl.MailProducerImpl.produce(MailProducerImpl.java:81)
            


            • 3. Re: [jBPM 4] Mai templates context variables
              tejjbpm

              There are few problems:

              1. Firstly the template named "task-assign" will be called you set notify="yes" in your task node. Only this template has access to #{taskInstance.name} not your custom template.
              2. If you want to use a custom template then you got to set the event as "task-assign" inside your

              For example:
              <event type="task-assign"> <mail name="mailtest" to="fdds@jfgj.com">
               <subject>Hello, there</subject>
               <text>Task instance name #{taskInstance.name} </text>
              </mail>
              </event>


              • 4. Re: [jBPM 4] Mai templates context variables
                gleenders

                I'm aware that I'm using the "task-assign" template and indeed i have set notify to 'yes'. Everything works fine except for the taskInstance variable. For the moment I'm not trying to make a custom template.

                • 5. Re: [jBPM 4] Mai templates context variables
                  tejjbpm

                  You did not get what I said. In the example you gave the name of your custom template as "task-notification". If you change that name to "task-assign" your taskinstance.name variable will work.

                  You are using custom template by changing the name of the template to "task-notification". The only system templates are "task-assign" and "task-reminder" which are by default present in jbpm.mail.templates. Whatever variables you want will work only under these two "SYSTEM DEFINED TEMPLATES"

                  • 6. Re: [jBPM 4] Mai templates context variables
                    kukeltje

                    @Gert
                    See my response to TejBPM below

                    @TejBPM
                    It has nothing to do with the templates, it has to do with the executionContext you are in. If you have a mail *node* like Gert initially had, there is no task instances there in the context. If you have an eventhandler and the event is task-assign, there *is* (afaik) a taskInstance in the execution context.

                    • 7. Re: [jBPM 4] Mai templates context variables
                      tejjbpm

                      That is what I said Ronald. If he is using a custom template in the mail node he cannot access it . He has to change it to task-assign event to get the handle of it and I gave a code sample of how to achieve it!!!!

                      • 8. Re: [jBPM 4] Mai templates context variables
                        kukeltje

                        Ok, then it might have been the way you said it (and do it again now) that I tried to correct your statement (you were right about using an event instead of node)

                        And to make it 100% clear now, it has nothing to do with 'using a custom template in a mailnode' it has to do with 'using a mailnode' ;-)

                        • 9. Re: [jBPM 4] Mai templates context variables
                          gleenders

                          Ok, I think a get the picture but i still have some problems.
                          First be aware that i'm using jBPM 4.

                          @TejJBPM:

                          The only system templates are "task-assign" and "task-reminder" which are by default present in jbpm.mail.templates. Whatever variables you want will work only under these two "SYSTEM DEFINED TEMPLATES"


                          the current manual descibes the following:
                          Table 6.15. task elements
                          Element Multiplicity Description
                          notification 0..1 Sends a notification message when a task is assigned. If no template is referenced or supplied inline, mail support falls back on the template named task-notification.
                          reminder 0..1 Sends a reminder message at specific intervals. If no template is referenced or supplied inline, mail support falls back on the template named task-reminder

                          So when i use the following


                          
                          <task duedate="10 seconds" g="36,108,97,52" name="Visa Conseiller">
                           <assignment-handler class="be.axi.bpm.handlers.TaskAssignmentHandler"/>
                           <notification/>
                           <reminder duedate="15 seconds"/>
                           <transition g="-76,-12" name="to Inspection" to="Inspection"/>
                          </task>
                          
                          <mail-template name="task-notification">
                           <to addresses="xxx@xxx.be" />
                           <subject>Assignment notification</subject>
                           <text>Task #{taskInstance.name} is assigned</text>
                           </mail-template>
                          


                          I assume that task-notification is a system template since i don't point to a specified template name (and regarding the manual).
                          This example works fine except for the context variables.

                          But i also tried the implementation you describe above i think the code you supplied above is from version 3
                          This is how my code look:

                          <task duedate="10 seconds" g="36,108,97,52" name="Visa Conseiller">
                           <assignment-handler class="be.axi.bpm.handlers.TaskAssignmentHandler"/>
                           <on event="task-assign"><mail template="mail-task-assign"></mail></on>
                           <reminder duedate="15 seconds"/>
                           <transition g="-76,-12" name="to Inspection" to="Inspection"/>
                           </task>
                          
                          <mail-template name="mail-task-assign">
                           <to addresses="xxx@xxx.be" />
                           <subject>Assignment notification (E-C)</subject>
                           <text>Task assigned</text>
                           </mail-template>


                          But this code does noting at all (even not an Error msg). Is this event still supported in jBPM 4?

                          Regards,
                          Gert

                          • 10. Re: [jBPM 4] Mai templates context variables
                            swatis

                            use just wild guess....:)

                            • 11. Re: [jBPM 4] Mai templates context variables
                              swatis

                              sorry msg didnot come properly
                              use

                              <on event="task-notification">
                              just wild guess....:)

                              • 12. Re: [jBPM 4] Mai templates context variables
                                tejjbpm

                                event type "task-notification" should work. In jbpm 4 "task-assign" is replaced with "task-notification" template.

                                • 13. Re: [jBPM 4] Mai templates context variables
                                  kukeltje

                                  I'm not 100% sure a mail element can be nested in a 'on' element in 4. But why not use the notify element with a template attribute?

                                  • 14. Re: [jBPM 4] Mai templates context variables
                                    gleenders

                                    Now we're back where we started :-) .... those silly loops....

                                    My initial try was this

                                    <task duedate="10 seconds" g="36,108,97,52" name="Visa Conseiller">
                                     <assignment-handler class="be.axi.bpm.handlers.TaskAssignmentHandler"/>
                                     <notification/>
                                     <reminder duedate="15 seconds"/>
                                     <transition g="-76,-12" name="to Inspection" to="Inspection"/>
                                    </task>
                                    
                                    <mail-template name="task-notification">
                                     <to addresses="xxxx@xxxi.be" />
                                     <subject>Assignment notification (E)</subject>
                                     <text>Task assigned</text>
                                    </mail-template>


                                    And this works fine except for the context variables, so my question rests the same....


                                    1 2 Previous Next