Share via


Adding Error Codes

When you use an eConnect SQL stored procedure to validate input parameters and perform business logic, you need to alert the caller when an error occurs. The eConnect error reporting system allows you to report these types of errors.

To use the eConnect error reporting system, you need to add error codes and messages for each validation or business logic check that you perform. The error code uniquely identifies your error message. The error message contains a brief description of the error that was detected.

The Dynamics GP Service framework uses the eConnect error reporting system to log errors identified by your SQL stored procedure in the Dynamics GP Web Services Exceptions console.

To provide error messages for your business objects errors, add your error codes and messages to the taErrorCodes table of the DYNAMICS (system) database. To add custom error information, complete the following procedure:

Open the Visual Studio solution

Use the same project you used for the SQL stored procedures. Open the solution in Visual Studio.

Add a SQL script file

From the Project menu, choose Add SQL Script. In the Add New Item window, click SQL Script in the list of Templates. Enter a name for your script file, and then click Add.

Create a SQL script

Use the SQL insert statement to add your error code and error message entries to the taErrorCode table of the DYNAMICS (system) database. The eConnect error reporting system requires you to specify an error code, the name of the stored procedure where the error occurs, and the error message to display. You can also supply the name of the field, and the parameter, but these are optional.

The following script sample shows how to add error information. Notice how each error code corresponds to an error code in the create/update or delete stored procedure samples.

USE DYNAMICS
GO

/* Add entries for the lead delete operation */
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61050','sampleLeadDelete','The Lead ID value cannot be null','LeadID','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61051','sampleLeadDelete','The Lead ID values is not valid','LeadID','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61052','sampleLeadDelete','The lead to be deleted does not exist','','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61053','sampleLeadDelete','An error occurred while deleting the specified lead','','')

/* Add entries for the lead create/update operation */
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61061','sampleLeadCreateUpdate','A required parameter was set to null','','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61062','sampleLeadCreateUpdate','The specified Potential Revenue or Business Category is not valid','','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61063','sampleLeadCreateUpdate','A Lead ID value was not supplied','LeadID','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61064','sampleLeadCreateUpdate','The Name value was not supplied','Name','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61065','sampleLeadCreateUpdate','The Salesperson was not specified','SLSPRSNID','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61066','sampleLeadCreateUpdate','The specified salesperson does not exist','SLSPRSNID','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61067','sampleLeadCreateUpdate','The Business Category value cannot be empty','BusCategory','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61068','sampleLeadCreateUpdate','The specfied Business Category value is not a valid entry','BusCategory','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61069','sampleLeadCreateUpdate','The value supplied for the Qualified property is not a valid entry','Qualified','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61070','sampleLeadCreateUpdate','Source and Qualification values cannot be set when the Qualifed field is false','Qualified','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61071','sampleLeadCreateUpdate','An error occurred during the insert operation the Lead was not created','','')
INSERT INTO dbo.taErrorCode(ErrorCode,SourceProc,ErrorDesc,ErrorKeyFields,ErrorParms)
 VALUES('61072','sampleLeadCreateUpdate','An error occurred during the update operation','','')

Save the file.

From the File menu, choose Save.