A database trigger responds to a new record created in Microsoft Dynamics GP if you specify TRIGGER_ON_DB_ADD in the table_operations parameter of the Trigger_RegisterDatabase() function. If successful, the database operation passes the added record’s buffer to your trigger processing procedure as an inout parameter.
This trigger creates a new third-party contact history record whenever the user adds a new customer record to the RM_Customer_MSTR table.
{Name: Startup} local integer l_result; l_result = Trigger_RegisterDatabase(anonymous(table RM_Customer_MSTR), form RM_Customer_Maintenance, TRIGGER_ON_DB_ADD, script IG_Create_Contact_History); if l_result <> SY_NOERR then warning "Database trigger registration failed."; end if;
This trigger processing procedure sets key values and default values, then saves a new contact history record corresponding to the new customer record.
{Name: IG_Create_Contact_History} inout table RM_Customer_MSTR; if not isopen(form IG_Contact_History) then 'Customer Number' of table IG_Contact_History_MSTR = 'Customer Number' of table RM_Customer_MSTR; 'Customer Name' of table IG_Contact_History_MSTR = 'Customer Name' of table RM_Customer_MSTR; First_Contact_Date of table IG_Contact_History_MSTR = sysdate(); Contact_Salesperson_ID of table IG_Contact_History_MSTR = 'Salesperson ID' of table RM_Customer_MSTR; save table IG_Contact_History_MSTR; end if;