Creating Deletion Rules for Relationships

You can set the deletion behavior of objects that are linked by a custom relationship. You can set different default deletion behavior for each related object, and you can define rules for exceptions to the default behavior. For example, if you create a custom relationship from Asset to Employee, you could set the deletion behavior to null out the employee reference on the asset when the employee is deleted. However, you might want to create an exception rule for employees that are contractors.
Deletion rule conditions are defined using the object model and can take the form of complicated logical expressions. Deletion rule conditions work in a similar manner to validation and state rule conditions.
You can create deletion rules for the following types of relationships:
You cannot create deletion rules for these types of relationships:
You can also select a custom message to be displayed instead of the generic deletion message.
This topic explains how to set up deletion rules for existing custom relationships:

To Set Default Deletion Behavior for a Custom Relationship

1.
2.
Select the Customization Center view.
3.
Click Lock for Customization. The APM icon in your Task bar now has a key on it:
4.
Note: You can set the deletion rules from either class in a relationship.
5.
6.
On the Data Members view, select the Custom Relationships tab.
7.
8.
Select the Deletion Rules tab.
9.
Delete: Deletes the related object without warning the user
Delete with warning: Deletes the related object, but warns the user. The user can cancel the deletion.
Do not delete: Neither object is deleted. An information message appears.
Do nothing: Nothing happens to the related object. (Not available for Scopes, Scoped by, References many, Referenced by many, or Referenced by relationship types.)
Set references to null: The reference to the related object is set to null (blank)
10.

To Enter Rules for Exceptional Behavior

1.
2.
Select the Deletion Rules tab.
3.
To add exceptions to the default behavior, click New. The Deletion rule dialog appears.
4.
5.
If you are basing the condition on an attribute in either the class being customized or a related class, select Attribute. For example, Classification is an attribute of the Asset class.
However, if the condition is to be based on the content of a relationship, select the Relationship option. For example, Asset Type (along with other value lists) is a separate class that is related to the Asset class.
For example, to create an exception for employees that are contractors you would select (starting from the Employee class):
Criterion type: Based on an attribute
Relationship from Asset: ContractorInfo
Attribute to test: Contractor
6.
Select the Type of value to test for:
Fixed: Select this option to test the condition based on a specific value that you enter.
See Fixed Value Settings.
Variable: Select this option to test a condition using a relative value. The value used in the filter is only determined at the time the filter is used by looking up the current value of the selected attribute or relationship. You can use any attribute or relationship that can be reached through a join path starting from the class that you are customizing. A specific value cannot be selected.
For example, you may want to test that Classification attribute of the asset’s parent matches that of the current asset. To do this you would set the join path to Hierarchy1 (which represents the relationship to the parent asset), and select Classification as the Test value attribute.
To create a variable value filter, see Variable Value Settings.
7.
Fixed Value Settings
Select a Test value. If are testing a fixed value, enter the specific value that you are testing for.
Variable Value Settings
8.
9.
Click OK to save the condition.
10.
11.
ANDed within a group, ORed between groups: items within the same group are evaluated with ANDs; items in different groups are evaluated with ORs.
ORed within a group, ANDed between groups: items within the same group are evaluated with ORs; items in different groups are evaluated with ANDs.
12.
For example, you might choose Do nothing when the condition “employee is a contractor” is met.
13.
If you have selected either the Do not delete or Delete with warning option, you can specify a custom message to display when the conditions are met. Select Display the following message instead of the generic deletion message, and then select the appropriate message from the list.
Note: To add a custom message, see Creating Custom Messages.
14.
15.

Testing the Rules

You should perform a thorough test of your rules, to ensure that the system behaves as you expected.
To test the rule, save and close the class, unlock the system, and navigate to the object to which the rule applies. Create some test objects and attempt to delete them under the conditions specified in your rules.