In this article
- Sending an email alert to a user or set of users based on a dynamic custom field after an asset is selected on a component.
Permissions required
- SYSTEM_SETTINGS_UPDATE (Creating custom fields)
- DROOLS_CREATION_RULE (Creating a custom drool)
Instructions
- Create a custom field on the primary project interface and define that field as a text field. This custom field on the project setup or project details interface will provide the input for which email address is used for this email notification. For more information on creating custom fields see - How to create a custom field/custom field type/custom field group
- Navigate to the Rules interface and select Drools from the available tabs on the rules interface.
- Select new rule and place this rule in the workflow module.
- Provide the following Drool syntax below (comments are notated by #) and select save.
package com.iriusrisk.drools;
import com.iriusrisk.drools.model.*;
import com.iriusrisk.drools.model.riskpattern.*;
import com.iriusrisk.model.*;
import com.iriusrisk.*;
import com.iriusrisk.drools.fact.*;
import com.iriusrisk.factories.DroolsValueConverter;
import com.iriusrisk.utils.EntityWithUDTUtil;
import com.iriusrisk.drools.fact.TagFact;
#provide a name for this rule
rule "ZZZ - PII Email Sending"
no-loop
when
$project : ProjectFact()
$component : ComponentFact()
#the following "fact" provides the basis for our action, which is the fact that "Personally Identifiable Information" is stored on an asset.
ComponentQuestionFact(id == "Personally Identifiable InformationStored", answer == true, componentReferenceId==$component.componentReferenceId);
#the following syntax defines that email custom field as a variable.
$pcf : ProjectCustomFieldFact(uniqueId == "Project Owner Email");
then
#this action inserts a notification that states that PII was selected on the notifications tab.
insertLogical(new com.iriusrisk.drools.model.ComponentNotification(NotificationType.INFO, "PII Stored", "PII Stored", $component.getComponentReferenceId()));
#the following action statement collects the previously defined variable and then sends that email address a notification email.
insertLogical(new NotifyUserActionEvent($project.getUniqueId(), "EMAIL", $pcf.getValue(), "Test", "Body"));
end
Testing this rule
- Create a new project and fill in the required custom field for the email address that should receive the notification email.
- Create a new threat model and assign the selected asset to that component.
- Update the threat model once prompted to update.
- Check the notifications tab to demonstrate that the rule ran successfully
- Check for the email notification
Comments
0 comments
Article is closed for comments.