Add an action hook
In this exercise, you create an action initialization hook for the Reassign action, which you added to the schema in the Create an action exercise. Initialization hooks let you perform complex operations at the beginning of an action. For example, you can use an action initialization hook to reset fields or assign different values to fields based on the type of action. The hook in this exercise is run when a user attempts to reassign a defect to another user. The hook clears the contents of the action_reason field. Users must make an entry in that field to complete the reassign action.
To add the action hook:
- In the Designer workspace, expand the Record Types folder, the Defect folder, and the States and Actions folder.
- To open the Actions grid, double-click Actions.
- Click in the Validation column cell for the Reassign action row. Click the down arrow and select .
- In the Visual Basic Script editor, insert the following code after the
line REM End If and before the line End Function:
' Empty the string at the beginning of the action SetFieldValue "action_reason", ""
- To compile the script, click . The script should compile without errors.
- Close the Script editor.
- Close the Actions grid.