Scenario: Looking to restrict the valid expense accounts during PO entry to specific accounts.

Example Solution:

  1. Add a custom validation in UD User Validation
  2. In the SQL tab, insert the code found below. Customize code to use your list of acceptable accounts.
  3. Press the compile button.
  4. In PO Purchase Order Entry, Press F3 on the GL Account field.
  5.  In the System Overrides tab, set Validation level to 2-Show error, disallow save or your choice.
  6. In the Procedure field find the custom validation you created.
  7. In the parameters field, input 115, 155 to pass the linetype and GL Account to the validation.
  8. Test the validation in a test environment to make sure if functions as expected.

SQL Query

/** User Defined Validation Procedure **/
        
/** Purpose: To restrict PO Entry with LineType 3 to Specified GL Accounts. **/
        
/** Created by Constructive Tech Solutions 3/19/2018 **/
(
    @linetype INT
    ,@GLAcct char(20) = Null           
    ,@msg varchar(255) output
)
AS

declare @rcode int
select @rcode = 0

IF 
    @linetype = 3 AND @GLAcct NOT IN ('99300.', '99250.')  --The Acceptable GL Accounts are listed here with a comma seperator 
    
BEGIN

    SELECT @rcode=1,@msg='Error invalid expense account for this PO Line Type' --Customize the error message here

END

spexit:

return @rcode