Correct Error Message Cannot Find fnInvoice_Credit_Amount (Internal)

Issue:

 

When working in an AP Vendor we are receiving errors that the application cannot find function or aggregate dbo.fnInvoice_Credit_Amount.

 

A screenshot of a computer screenDescription automatically generated

Resolution:

The function is used by the application and cannot be found as expected. There may have been a problem when the database was updated, and the function was not created correctly, or the function was deleted from the database by mistake.

 

The script below will recreate the function if it no longer exists.

 

/****** Object:  UserDefinedFunction [dbo].[fnInvoice_Credit_Amount]    Script Date: 11/20/2024 3:51:34 PM ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

 

CREATE FUNCTION [dbo].[fnInvoice_Credit_Amount] 

     (@APInvoice_Id int)

     RETURNS money

AS

BEGIN

     DECLARE @Amount money

     SELECT @Amount = SUM(cd.Amount)

     FROM AP_Credit_Detail cd 

     WHERE cd.APInvoice_Id = @apinvoice_id

     RETURN @Amount

END

GO

Was this article helpful?
Thank you for your feedback!
User Icon

Thank you! Your comment has been submitted for approval.