web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Automating Payable in VB.Net - How to check for Duplicate Invoice Numbers popup.

(0) ShareShare
ReportReport
Posted on by

I have recently coded software for the intent of automating account payables. However, I have encountered a problem with duplicate invoices. If invoices were to be entered manually, then there would be a popup that prevents the program from saving the invoice but if were automated, the popup would be ignored. Would there be any code that could be used so that my program can recognize when a popup for a duplicate invoice number occurs?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    JamesLyn Profile Picture
    360 on at

    I am not sure how you are coding this, but I would check to see if the invoice number exists before even trying to enter it. I have written code in c#, but I would assume the libraries are similar for VB. Below is an example of how to query a table and check the results in c#

               //Search for document number

               Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.Key = 3;

               Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.DocumentNumber.Value = docNum;

               TableError err = Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.Get();

               if (err == TableError.NoError)

               {

                 //Invoice exists

               }

               else

               {

                  //Invoice does not exist

               }

    ~James

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    That must be happening because on manually entering invoice will trigger your event on which you are verifying for existing invoice, whereas in your automated solution there is no such check added by you, so you need to ass piece of code as mentioned by James.

  • Community Member Profile Picture
    on at

    Okay cool, great idea. I was thinking of using Payables Transaction Inquiry for a query. However, I still have to isolate the Vendor ID and then use a query to find the document number to see if there is a duplicate. So, any tips on how to do that, I'm really inexperienced. Literally just a student intern.

  • Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    I am confused, if you are creating payables transaction Invoice (automatically) then your code should read the next available invoice number from the setup and in this way it will always read the new number, you don't need to validate for used or duplicate one.

    4035.payables.png

  • Community Member Profile Picture
    on at

    Okay, I've read up on the manual and did a bit of code. Everything is somewhat working but I'm running into a little bit of a different problem now. Validation works fine for all posted invoice numbers but fails to work for unposted invoices that are still in "work" as they somehow are not recognized . Is there another table for invoices that have not been posted yet?

    This is my final code if anyone might need it later.

    Dim CustomerMasterTableID As PmPaidTransactionHistTable

           Dim CustomerMasterInvoiceVendor As PmPaidTransactionHistTable

           Dim TabErr As TableError

           Dim VendErr As TableError

           CustomerMasterTableID = Dynamics.Tables.PmPaidTransactionHist

           CustomerMasterInvoiceVendor = Dynamics.Tables.PmPaidTransactionHist

           ' Find the proper keys

           CustomerMasterInvoiceVendor.Key = 1

           CustomerMasterTableID.Key = 3

           ' Used Vendor and Invoice to symbolize the two variables that I was looking for; vendorname and invoicenumber.

           CustomerMasterTableID.DocumentNumber.Value = invoice

           CustomerMasterInvoiceVendor.VendorId.Value = VendorId

           'Retriving the error

           TabErr = CustomerMasterTableID.Get()

           VendErr = CustomerMasterInvoiceVendor.Get()

           If TabErr = TableError.NoError And VendErr = TableError.NoError Then

               Error 123

           Else

           End If

           CustomerMasterInvoiceVendor.Close()

           CustomerMasterTableID.Close()

  • Verified answer
    JamesLyn Profile Picture
    360 on at

    Try the following tables:

    'Current Documents

    Microsoft.Dexterity.Applications.Dynamics.Tables.PmTransactionOpen;

    'Unposted Documents

    Microsoft.Dexterity.Applications.Dynamics.Tables.PmTransactionWork

  • Community Member Profile Picture
    on at

    Yep, got that. Thanks!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans