Description of Issue:
When attempting to open documents or add documents to Any Vendor records or transactions an error is returned.
How can this be corrected?
Resolution:
This error can be caused by the Credit_Id field not being found in the AP_Vendor_Document table.
You will need the add the field to the table using the scripts below.
The stored procedures will also need to be updated to be sure they include the added field.
To see if this is the issue, run the script below. You should see the Credit_id at the end of the row.
Use SedonaDocumentsSelect top 1 * From AP_Vendor_Documents
If the field is not in the results, run this first set of scripts to add the field to the table.
--- Add Credit_id field to AP_Vendor_Documents ------ Users will see errors in AP trying to view or add documents in AP applications ------ Error 3265 Item cannot be found in the collection corresponding to the requested Name or ordinal ---Use SedonaDocuments--- Add field to the table ---ALTER TABLE AP_Vendor_Documents ADD Credit_Id int NOT NULLGo--- Add the Default value for the field when new record is created ---ALTER TABLE [dbo].[AP_Vendor_Documents ] ADD DEFAULT ((1)) FOR [Credit_Id]Go--- Update field with the default value of 1 ---update AP_Vendor_Documentsset credit_id =1where credit_ID is nullGo--- Update the field to not Allow Nulls after the default value has been populated. ---ALTER TABLE AP_Vendor_Documents ALTER COLUMN Credit_Id INT NOT NULL
Run this second set of scripts to drop and recreate the stored procedures that access this table.
Drop and recreate the Vendor_Documents_GET stored procedure.
Use SedonaDocumentsDROP PROCEDURE IF EXISTS dbo.Vendor_Documents_GETGOUSE [SedonaDocuments]GO/****** Object: StoredProcedure [dbo].[Vendor_Documents_GET] Script Date: 8/5/2022 8:33:20 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[Vendor_Documents_GET]@company_id int,@vendor_id int,@document_id intASIF(@document_id = 0)BEGIN SELECT doc.Document_Id, doc.SedonaCompany_Id, doc.Vendor_Id, doc.Security_Level, doc.FileName, doc.FileSize, doc.UploadDate, typ.Document_Extension, typ.Document_Type_Description, typ.Type_US, doc.UserDescription, doc.UserCode, doc.Invoice_Id, doc.Check_Id, doc.Purchase_Order_Id, doc.Receipt_Id, doc.Reference_1, doc.Reference_2, doc.Reference_3, Credit_IdFROM AP_Vendor_Documents docINNER JOIN SY_Document_Type typ ON typ.Document_Type_Id = doc.Document_Type_idWHERE doc.SedonaCompany_Id = @company_id AND doc.Vendor_Id = @vendor_idENDELSEBEGINSELECT doc.Document_Id, doc.SedonaCompany_Id, doc.Vendor_Id, doc.Security_Level, doc.FileName, doc.FileSize, doc.UploadDate, typ.Document_Extension, typ.Document_Type_Description, typ.Type_US, doc.UserDescription, doc.UserCode, doc.Invoice_Id, doc.Check_Id, doc.Purchase_Order_Id, doc.Receipt_Id, doc.Reference_1, doc.Reference_2, doc.Reference_3, Credit_IdFROM AP_Vendor_Documents docINNER JOIN SY_Document_Type typ ON typ.Document_Type_Id = doc.Document_Type_idWHERE doc.SedonaCompany_Id = @company_id AND Vendor_Id = @vendor_id AND doc.Document_Id = @document_idENDGO
Drop and recreate the Vendor_Document_ADD stored procedure.
Use SedonaDocumentsDROP PROCEDURE IF EXISTS dbo.Vendor_Document_ADDGOUSE [SedonaDocuments]GO/****** Object: StoredProcedure [dbo].[Vendor_Document_ADD] Script Date: 8/5/2022 8:28:29 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROC [dbo].[Vendor_Document_ADD]@company_id int,@vendor_id int,@security_level int,@file_name nvarchar(255),@file_size int,@upload_date datetime,@document_ext nvarchar(25),@user_code nvarchar(25),@user_description nvarchar(50),@reference1 nvarchar(50),@reference2 nvarchar(50),@reference3 nvarchar(50),@file_data image,@invoice_id int,@check_id int,@purchase_order_id int,@receipt_id int,@credit_id int = 1,@document_id int OUTPUTASDECLARE @doc_type_id intEXEC Get_Document_Type_Id @document_ext, @doc_type_id OUTPUTIF @doc_type_id = 1BEGININSERT SY_Document_Type(Document_Extension, Document_Type_Description, Type_US)VALUES(@document_ext, @document_ext, 'U')SET @doc_type_id = SCOPE_IDENTITY()ENDSELECT @document_id = 0INSERT AP_Vendor_Documents(SedonaCompany_Id, Vendor_id, Security_Level, FileName, FileSize, FileData, UploadDate, Document_Type_Id, UserCode, UserDescription , Reference_1, Reference_2, Reference_3, Invoice_Id, Check_Id, Purchase_Order_Id, Receipt_Id, Credit_Id)VALUES(@company_id, @vendor_id, @security_level, @file_name, @file_size, @file_data, @upload_date, @doc_type_id, @user_code, @user_description , @reference1, @reference2, @reference3, @invoice_id, @check_id, @purchase_order_id, @receipt_id, @credit_id)IF @@error = 0BEGINSELECT @document_id = @@IDENTITYENDRETURNGO
Drop and recreate the Vendor_Document_UPD stored procedure.
Use SedonaDocumentsDROP PROCEDURE IF EXISTS dbo.Vendor_Document_UPDGOUSE [SedonaDocuments]GO/****** Object: StoredProcedure [dbo].[Vendor_Document_UPD] Script Date: 8/5/2022 8:30:07 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROC [dbo].[Vendor_Document_UPD]@operation_type int,@document_id int,@security_level int,@file_name nvarchar(255),@file_size int,@upload_date datetime,@document_ext nvarchar(25),@user_code nvarchar(25),@user_description nvarchar(50),@reference1 nvarchar(50),@reference2 nvarchar(50),@reference3 nvarchar(50),@invoice_id int,@check_id int,@purchase_order_id int,@receipt_id int,@credit_id int = 1,@file_data image = defaultASDECLARE @doc_type_id intEXEC Get_Document_Type_Id @document_ext, @doc_type_id OUTPUTIF @operation_type = 0BEGINUPDATE AP_Vendor_Documents'SET Security_Level = @security_level,FileName = @file_name,FileSize = @file_size,UploadDate = @upload_date,Document_Type_Id = @doc_type_id,UserCode = @user_code,UserDescription = @user_description,Invoice_Id = @invoice_id,Check_Id = @check_id,Purchase_Order_Id = @purchase_order_id,Reference_1 = @reference1,Reference_2 = @reference2,Reference_3 = @reference3,Credit_Id = @credit_idWHERE Document_Id = @document_idENDIF @operation_type = 1BEGINUPDATE AP_Vendor_DocumentsSET Security_Level = @security_level,FileName = @file_name,FileSize = @file_size,UploadDate = @upload_date,Document_Type_Id = @doc_type_id,UserCode = @user_code,UserDescription = @user_description,FileData = @file_data,Invoice_Id = @invoice_id,Check_Id = @check_id,Purchase_Order_Id = @purchase_order_id,Reference_1 = @reference1,Reference_2 = @reference2,Reference_3 = @reference3,Credit_Id = @credit_idWHERE Document_Id= @document_idENDIF @@error <> 0BEGINRETURNENDGO