In some cases, you may want to set a variable in a scenario and then reference the variable in the body of an e-mail message that the scenario sends out (using either the EmailNotify
or the SendEmail
action). In the following example, you set up a scenario that watches for a customer to make a purchase, tracks the order ID in a variable called orderNumber
and the date the order was placed in a variable called orderDate
, and then sends the customer an e-mail that includes both pieces of information. The scenario includes the following elements:
![](media/image22.png)
You could then add the following lines to the email template orderreceived.jsp
:
<p>Order number <dsp:valueof param="context.processInstance.contextStrings.orderNumber"/> <p>was received on <dsp:valueof param="context.processInstance.contextDates.orderDate"/>
(Note: The context variable is bound to the template at runtime, so the value of the variable does not appear if you simply preview the template in a Web browser, for example by using the preview features in the ACC. If you want to make sure that the correct values appear, set up a test e-mail address and send the message to it.)
The valueof
tag references the process execution context, an implementation of the interface processExecutionContext
that extends the atg.process
package. The following properties of the context component are available for use in the e-mail template:
processInstance
. An instance of anindividualScenario
repository item descriptor. (The definition of this repository item is contained in the defaultuserProfile.xml
file.)subject
. An instance of theuser
repository item descriptor.messageType
. A String that represents the JMS type of the message that triggered the scenario.individual
. A Boolean property that indicates whether the scenario context is collective (false), which means it applies to all users passing through the scenario, or individual (true), which means it applies only to individual users. Note that, although you can use either value of this boolean property in the body of an e-mail, only individual process instances (seeprocessInstance
above) will contain a context that can be used to extract the value of a variable set during the scenario.
The page compiler uses Dynamic Beans to reference subproperties of these context elements. In the example above, contextStrings
and contextDate
are subproperties of the processInstance
. Other processInstance
subproperties that you can reference in this way are as follows:
contextBooleans
contextLongs
contextDoubles
For more information on Dynamic Beans, refer to the ATG Platform Programming Guide.