Entity-level scripts
Entity-level scripts and entity-level with rollback scripts are executed when an entity is inserted, updated, or deleted.
- Use entity-level scripts when an action is dependent on the whole entity. For example, you want to do something when a whole Company is inserted, not just when a record is added to the Company table.
- Use entity-level with rollback scripts when you want to stop an action if a script error occurs.
You can use entity-level scripts on the following entities: Company, Person, Email, and Address. The scripts are invoked from the following standard Sage CRM screens when you click the final Save.
Screen |
EntityScript |
Method |
---|---|---|
New Company |
Company |
InsertRecord() |
Change Company |
Company |
UpdateRecord() |
Delete Company |
Company |
DeleteRecord() |
New Person |
Person |
InsertRecord() |
Change Person |
Person |
UpdateRecord() |
Delete Person |
Person |
DeleteRecord() |
Edit Phone/E-mail |
|
UpdateRecord() |
New Address |
Address |
InsertRecord() |
Edit Address |
Address |
UpdateRecord() |
Delete Address |
Address |
DeleteRecord() |
For example, with an InsertRecord entity-level script attached to Company, each time you create a new Company, the InsertRecord() function is executed when all the normal Company updates are complete but before the final commit. Normal Company updates include inserts into many tables. For example, address, address_link, phone, email, person, person_link.
If an error occurs while executing an entity-level with rollback script, all changes are undone and the Company is not inserted. The error is displayed on the insert screen.