| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > FileManager > FileManager Methods >====== PreInsert(trigger insert action pre-processing) ====== | [[predelete trigger delete action pre processing .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[preupdate trigger update action pre processing .htm|{{btn_next_n.gif|Next page}}]] | | || **PreInsert(**//OpCode, AddLength ErrCode, ErrMsg //**), **//returncode// | **PreInsert** | Returns confirmation that valid dictionary trigger activity has occurred before an insert action, and optionally sets an error code and message to be processed. | | //OpCode// | A SIGNED integer that indicates the type of ADD that will be attempted. | | //AddLength// | An UNSIGNED integer that indicates the record length about to be added when the ADD ( File, Length) mode is active. | | //ErrCode// | A string constant, variable, EQUATE, or expression that represents an error code. | | //ErrMsg// | A string constant, variable, EQUATE, or expression that represents an error message. | | //returncode// | Indicates if an error occurs. | The **PreInsert **method is a virtual method that returns a TRUE value by default if pre-insert trigger activity was processed normally. The developer must set the return level to FALSE if any problems occurred in the pre-insert trigger activity code. When **PreInsert** returns FALSE, an ERRORCODE 100 (trigger error) is posted. If //ErrCode// is set, then FILEERRORCODE will be set to the contents of //ErrCode// when the error is processed by the ErrorClass object for the associated file (table). Similarly, FILEERROR will be set to //ErrMsg//. The //OpCode// and //AddLength// parameters can be used in your pre-processing trigger code. | DriverOp:ADD | ADD(FILE) | | DriverOp:Append | APPEND(FILE) | | DriverOP:AddLen | ADD(FILE,LENGTH) | | DriverOp:AppendLen | APPEND(FILE,LENGTH) | Use the Equates provided in EQUATES.CLW (shown above) to test the //OpCode//. //AddLength// is used to return the value of the length parameter if used with ADD. The **PreInsert** method is accessible from a table's trigger properties located in the Dictionary Editor, or, in the Global Embeds of a target application **Implementation:** PreInsert is implemented using the file driver callback mechanism, therefore, this method will have access to all variables that the File Manager has access to. These variables and the ones added in the Data section of the method will allow the developer to insert code that will be executed before an INSERT action for a file. **Return Data Type:**     BYTE **Example:** **  CODE** **  PUSHERRORS()** **  ReturnValue = PARENT.****PreInsert****(OpCode,AddLen,ErrCode,ErrMsg)** **   MESSAGE('Trigger Test Before Insert')** **   !Trigger code entered here** **  POPERRORS()** **  RETURN ReturnValue** **See Also:**     [[postinsert trigger insert action post processing .htm|PostInsert]] , [[predelete trigger delete action pre processing .htm|PreDelete]] , [[preupdate trigger update action pre processing .htm|PreUpdate]]