Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Creating a Record in Vendor Invoice in vendor collaboration screen.

Posted on by 117
I am creating an uploader to upload invoices on the vendor collaboration screen. The invoices get created but I am not able to see the line in the invoice. The amount appears on the header but no line is displayed on the form. Below are the attached SS and code that I am using. Please help me find the missing link.
 
Header SS: Amount appearing.
Lines SS: No line is appearing.
Code:
if (UploadVendorInvoices::validateInvoiceId(invoiceNumber, vendorId)) {select vendInvoiceInfoTable where vendInvoiceInfoTable.Num == invoiceNumber;if (!vendInvoiceInfoTable) {VendTable vendTable = VendTable::find(vendorId);vendInvoiceInfoTable.clear();vendInvoiceInfoTable.initValue();vendInvoiceInfoTable.Ordering = DocumentStatus::Invoice;vendInvoiceInfoTable.DocumentOrigin = DocumentOrigin::VendorPortal;vendInvoiceInfoTable.ParmId = formletterParmData::getNewParmId();vendInvoiceInfoTable.TableRefId = formletterParmData::getNewTableRefId();vendInvoiceInfoTable.DocumentDate = invoiceDate;//vendInvoiceInfoTable.FixedDueDate = invoiceDate;vendInvoiceInfoTable.Num = invoiceNumber;vendInvoiceInfoTable.InvoiceAccount = vendorId;vendInvoiceInfoTable.OrderAccount = vendorId;vendInvoiceInfoTable.Payment = vendTable.PaymTermId;vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, Payment));vendInvoiceInfoTable.PurchName = vendTable.name();vendInvoiceInfoTable.TaxGroup = vendTable.TaxGroup;vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, InvoiceAccount));vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, OrderAccount));vendInvoiceInfoTable.Description = invoiceDescription;vendInvoiceInfoTable.ParmJobStatus = ParmJobStatus::Waiting;if (currencyCode != '') {vendInvoiceInfoTable.CurrencyCode = currencyCode;}if (vendInvoiceInfoTable.validateWrite()) {vendInvoiceInfoTable.insert();}vendInvoiceInfoLine.clear();vendInvoiceInfoLine.initValue();select RecId from ecoResCategory where ecoResCategory.Name == procurmentCat;vendInvoiceInfoLine.ProcurementCategory = ecoResCategory.RecId;vendInvoiceInfoLine.DSSProjid = ProjId;vendInvoiceInfoLine.DSSProjCategory = ProjCat;vendInvoiceInfoLine.DSSCustInvoiceId = clientInvoiceId;vendInvoiceInfoLine.PurchPrice = invoiceAmount;vendInvoiceInfoLine.ReceiveNow = quantity;vendInvoiceInfoLine.ParmId = vendInvoiceInfoTable.ParmId;vendInvoiceInfoLine.TableRefId = vendInvoiceInfoTable.TableRefId;vendInvoiceInfoLine.modifiedField(fieldNum(VendInvoiceInfoLine, PurchPrice));if (vendInvoiceInfoLine.validateWrite()) {vendInvoiceInfoLine.insert();}}}
 
  • ShahzaibAhmed52 Profile Picture
    ShahzaibAhmed52 117 on at
    Creating a Record in Vendor Invoice in vendor collaboration screen.
    Yes There are lines inserted in vendInvoiceInfoLine. They appear in SQL and Table browsers. But Not on Invoice screen.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,332 Super User 2024 Season 2 on at
    Creating a Record in Vendor Invoice in vendor collaboration screen.
     
    Did you check if vendInvoiceInfoLine table save your line? also did you try to debug the code? and see if the validateWrite method is returned true on vendInvoiceInfoLine table?
     
     
    Regards,
    Waed Ayyad
  • ShahzaibAhmed52 Profile Picture
    ShahzaibAhmed52 117 on at
    Creating a Record in Vendor Invoice in vendor collaboration screen.
    Here is the formatted code. Yes the record exists in the Lines table
     
    if (UploadVendorInvoices::validateInvoiceId(invoiceNumber, vendorId)) {
    	select vendInvoiceInfoTable where vendInvoiceInfoTable.Num == invoiceNumber;
    	
    	if (!vendInvoiceInfoTable) {
    		VendTable vendTable = VendTable::find(vendorId);
    		
    		vendInvoiceInfoTable.clear();
    		vendInvoiceInfoTable.initValue();
    		vendInvoiceInfoTable.Ordering = DocumentStatus::Invoice;
    		vendInvoiceInfoTable.DocumentOrigin = DocumentOrigin::VendorPortal;
    		vendInvoiceInfoTable.ParmId = formletterParmData::getNewParmId();
    		vendInvoiceInfoTable.TableRefId = formletterParmData::getNewTableRefId();
    		vendInvoiceInfoTable.DocumentDate = invoiceDate;
    		//vendInvoiceInfoTable.FixedDueDate = invoiceDate;
    		vendInvoiceInfoTable.Num = invoiceNumber;
    		vendInvoiceInfoTable.InvoiceAccount = vendorId;
    		vendInvoiceInfoTable.OrderAccount = vendorId;
    		vendInvoiceInfoTable.Payment = vendTable.PaymTermId;
    		vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, Payment));
    		vendInvoiceInfoTable.PurchName = vendTable.name();
    		vendInvoiceInfoTable.TaxGroup = vendTable.TaxGroup;
    		vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, InvoiceAccount));
    		vendInvoiceInfoTable.modifiedField(fieldNum(vendInvoiceInfoTable, OrderAccount));
    		vendInvoiceInfoTable.Description = invoiceDescription;
    		vendInvoiceInfoTable.ParmJobStatus = ParmJobStatus::Waiting;
    
    
    		if (currencyCode != '') {
    			vendInvoiceInfoTable.CurrencyCode = currencyCode;
    		}
    
    		if (vendInvoiceInfoTable.validateWrite()) {
    			vendInvoiceInfoTable.insert();
    		}
    			
    		vendInvoiceInfoLine.clear();
    		vendInvoiceInfoLine.initValue();
    			
    		select RecId from ecoResCategory where ecoResCategory.Name == procurmentCat;
    			
    		vendInvoiceInfoLine.ProcurementCategory = ecoResCategory.RecId;
    		vendInvoiceInfoLine.DSSProjid = ProjId;
    		vendInvoiceInfoLine.DSSProjCategory = ProjCat;
    		vendInvoiceInfoLine.DSSCustInvoiceId = clientInvoiceId;
    		vendInvoiceInfoLine.PurchPrice = invoiceAmount;
    		vendInvoiceInfoLine.ReceiveNow = quantity;
    		vendInvoiceInfoLine.ParmId = vendInvoiceInfoTable.ParmId;
    		vendInvoiceInfoLine.TableRefId = vendInvoiceInfoTable.TableRefId;
    		vendInvoiceInfoLine.modifiedField(fieldNum(VendInvoiceInfoLine, PurchPrice));
    
    		if (vendInvoiceInfoLine.validateWrite()) {
    			vendInvoiceInfoLine.insert();
    		}
    	}
    }
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,332 Super User 2024 Season 2 on at
    Creating a Record in Vendor Invoice in vendor collaboration screen.
     
    Can you add your code on a comment? So we can help you better. Also did you check if the line table has the records or not?
     
    Regards,
    Waed Ayyad

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans