In E-mail messages you can change the context of the template according to the To field.
Keep in mind that the context changes in E-Mails apply to one-to-many relationships, when the To filed contains a collections of E-Mail addresses.
Remember that when you have a one-to-many relationship between two entities, an attribute is automatically created in the Collection Entity (many) relating it to the Parent Entity (one). This attribute is the available to access to the parent process attributes starting from the many context. So when you change the Context of an E-Mail to the Many Entity, you will still be able to access information of the One Entity.
•When the To field contains a fixed e-mail address or it is taken from a Related-entity relationship of the Data Model, the context will always be the Process Entity.
•When the To filed contains a collection, you can choose between the Process Entity or the Many Entity as you context.
Referring to the example in the previous section, imagine you are a Wedding Planner and you use Bizagi to plan weddings. The image below shows the data model for this Process. The Process Entity is Wedding which has a one to many relationship with the Guests entity where the couple registers the information of each person who is going to attend the ceremony. An established time before the wedding all invitations are sent via E-mail to every person included in the collection of Guests.
When the addressees in the To field are obtained through Related-attributes (a one to one relationship), the typed message and the conditions of multiple messages will all have the same context. That is, the data will be accessed in the same way, starting from the Process Entity.
When the addressees belong to a collection, in our example a collection of Guests, the context of the message body and the context of the conditions can be chosen.
You can type the message navigating the data model as usual, from the Process Entity Wedding, but you can also navigate the data model from the many entity, Guests.
If navigating the model from the many entity, there is a change of context. The context changes to the many entity. In this case, corresponds to Guests. The Wedding entity is no longer the context entity.
When the collection of Guests has been selected in the To field you can change the context of the E-Mail and write it using the Wedding entity as context, or you can write it using the Guests entity as context. Which ever you choose will be the starting point when navigating the data model in your E-Mail.
Context in the E-Mail body
Continuing with the example mentioned before, note that in the previous section we did not include the guest's name in the message body. If you need to access this information you must change the context of the message body.
You wish to include the following information in the E-mail:
You are cordially invited to the wedding of
on Saturday afternoon
May the 2nd
at four o'clock
Thirty five west Leicester Avenue
followed by a reception
You want to include the Guest's name, the Groom's name and Bride's name. These information is obtained from attributes of the data model.
If you need to access this information you must change the context of the message body to the many Entity, Guests. If you use the Process Entity as context (Wedding) you can access the Groom's name and Bride's name inserting the Xpath as we have seen in previous examples. However, you cannot access to the Guest's name because the attribute is in the collection Guest. If you were to use a Xpath definition to access the Guest entity you would obtain the list of all guest's names instead of a specific guest name.
In this scenario you need to change the context of the body in the Context drop-down list located at the top right of the E-mail configuration menu.
The Context option is enabled when the To field contains a collection.
Choose the Guests context. You can now access the guest's name directly from the Guest entity.
To access the Groom's and Bride's names you must select the Xpath using the relationship from the many entity to the Process Entity as displayed below.
This way you can complete the desired message
This is how the e-mails will look like:
Context in the Conditions
Suppose you want to differentiate between men and women in the invitation, to include the word "Mr." or "Ms." in front of the guest's name.
In order to do this include Multiple messages with their specific conditions according to the guest's gender.
In the E-mail configuration menu, check the Multiple Message box and include a new E-mail by clicking the last tab.
Click the Set Conditions option. A new window will be displayed. Since the To filed has a collection, Conditions can change context from the drop-drown list on the bottom of the menu.
If you wish to access the information of guests individually and not as a collection, you have to change the context. Since you need to access the gender of each guest, you need to select the Guests context.
Conditions will be established from the Guests entity.
Type the subject and the body for the second e-mail, addressed to female guests.
This is how the respective emails will look: