This example expands the query detailed in "JavaScript onDelete Function Example 1: Checking a Single Condition" [ |http://#_bookmark111]by by showing how to prevent open activities from being deleted if the parent (Account) is a customer. In this case, deleting records that are open for prospects is allowed, but not for customers. The following assumptions are made in this example:
...
Code Block |
---|
<html><head><title>OnDeleteExample2</title> <script type="text/javascript"> function fieldsOnDelete(){ return "CALTYPE,1.ACCTKW01";} function onDelete(Type,AccountType){ if( Type == 'Call' && AccountType == 'Prospect' ){ window.location = "MELT://showAlert:/ You cannot delete open Call Activities from Prospect Accounts"; return false; }else{ return true; } } </script></head><body></Body><body></html> |
where:
- function fieldsOnDelete(){ return "CALTYPE"; } is enhanced to include a second field to check for. A comma is inserted first to indicate another field, and as that field is in a parent module, the Module ID of the parent object must be included with a period symbol (.) separating the module ID and field name. The code in onDelete example 2 is as follows:
...