cancel
Showing results for 
Search instead for 
Did you mean: 

Field injection on email task not working

ericsnyder
Champ on-the-rise
Champ on-the-rise
I have the following email task that is trying to use the value of the field "description" in the subject line and text.
    <serviceTask id="mailtask1" name="Mail Task" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to">
          <activiti:expression>#{emailAddresses.convert(emailTo)}</activiti:expression>
        </activiti:field>
        <activiti:field name="from">
          <activiti:string>no-reply@sharpline.com</activiti:string>
        </activiti:field>
        <activiti:field name="subject">
          <activiti:string>${description}</activiti:string>
        </activiti:field>
        <activiti:field name="text">
          <activiti:string>${description} is approved.</activiti:string>
        </activiti:field>
        <activiti:field name="cc">
          <activiti:expression>#{emailAddresses.convert(emailCC)}</activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>

I get the literal text "${description} rather than the value for the variable "description".

Bug? How do I get this resolved? I really need to get this running so I can move on to something else.

BY the way, this is working:
<activiti:expression>#{emailAddresses.convert(emailTo)}</activiti:expression>
2 REPLIES 2

ronnybr
Champ in-the-making
Champ in-the-making
Well, it makes sense, that you get the text ${description} when using activiti:string.
I'd use, like you mentioned, <activiti:expression> every time you refer to some process variable with ${…}.
So using
<code>
        <activiti:field name="subject">
          <activiti:expression>${description}</activiti:expression>
        </activiti:field>
</code>
or alternatively
<code>
<activiti:field name="subject" expression="${description}" />
</code>
should work.

ericsnyder
Champ on-the-rise
Champ on-the-rise
ronnybr:
Thanks, I see what is going on. I was using the graphical editor to set up the fields. It looks like some of the fields (text and subject in this case) are not recognizing when an expression is being placed in them to wrap them with the proper tags in the xml file.

I see now in the documentation that there are a few different <activiti:???> tags. In this case the graphical editor was using <activiti:string> when it needed to be <activiti:expression>.

Thanks for the pointer.