Here are the steps to do this:
1. Create an email template. In this example, the filename is "myEmailTemplate", which is stored as "'myEmailTemplate.html". This filename will be used in the trigger code.
2. Create a group in ProcessMaker named "Users to Notify" which contains all the users who can receive the email.
3. Then, create a DynaForm which contains a checkgroup associated with a case variable named "usersToNotify".
4. Then, create an array variable in process designer with the name "availableUsersToNotify".
5. In the properties of the "usersToNotify" checkgroup in the DynaForm designer, set the "data source" to "Array Variable" and the "data variable" to @@availableUsersToNotify. See:
http://wiki.processmaker.com/3.0/DynaFo ... Datasource
6. Add the following trigger to your process:
Code: Select all@=availableUsersToNotify = array();
$groupId = PMFGetGroupUID("Users to Notify");
if (!empty($groupId)) {
$aUsers = PMFGetGroupUsers($groupId)
foreach ($aUsers as $aUser) {
@=availableUsersToNotify[] = array($aUser['USR_EMAIL'], $aUser['USR_FIRSTNAME'] .' '. $aUser['USR_LASTNAME']);
}
}
Set this trigger to fire before the DynaForm containing the checkgroup.
7. Add the following trigger to your process:
Code: Select allif (isset(@=usersToNotify) and !empty(@=usersToNotify)) {
$to = '';
foreach(@=usersToNotify as $email) {
$to = (empty($to) ? '' : ', ') . $email;
}
PMFSendMessage(@@APPLICATION, 'admin@example.com', $to, '', '', 'My email subject line', 'myEmailTemplate.html');
}
Set this trigger to fire after the DynaForm containing the checkgroup.
See the documentation for all functions in the trigger code so you understand what the code does.