Author Topic: Purchase Orders - RefNumber  (Read 1356 times)

mikedbell

  • Member
  • *
  • Posts: 7
Purchase Orders - RefNumber
« on: April 11, 2013, 12:28:50 PM »
How can I query QB to find out the last Purchase Order Number (RefNumber) used? It seems like it should be an easy thing to do.

Geoffrey Gerhard

  • Guru
  • Member
  • ****
  • Posts: 470
Re: Purchase Orders - RefNumber
« Reply #1 on: April 11, 2013, 01:05:16 PM »
It's not as easy as it seems. If the QB users never override the auto-entered PO Number it becomes a little easier, but not much. You'll need to create a Query Request that returns a set of records that includes the most recently created record, which can be tricky unless you know that at least one PO will have been created in the last n days. If n = 7, use the ModifiedDateRangeFilter and set the value of FromModifiedDate in your query to the current date - 7, formatted appropriately.

You'll need to parse the Response for the max value of the TimeCreated element. Once you know which (if more than one) PurchaseOrderRet node has the most recent TimeCreated value you can retrieve that node's RefNumber value.

Is your goal only the most recent PO Number, or is it really about obtaining the highest number used? If so, and even if a QB user might override the PO Number, as long as the number is consistently formatted (same length, number of characters, position of any separators), you can do a similar Query and parse the RefNumber values to find the highest value.

HTH!

Geoffrey Gerhard
Creative Solutions Incorporated
14000 Creekside Drive
Matthews, NC  28105
704) 814-6852

mikedbell

  • Member
  • *
  • Posts: 7
Re: Purchase Orders - RefNumber
« Reply #2 on: April 16, 2013, 12:31:04 PM »
Mr. G,

Thank You for your reply! I'm on the right track now. I'm pulling the RefNumbers for the last week and parsing the result for the appropriate value.

Thanks again!
Mike Bell
Enbel Data Systems