PurchaseOrderAdd

Adds one PurchaseOrder to the QBPOS company.


Request

Response

XMLOPS

VB.NET

C#

Tag Type Max length Implementation Required

IPurchaseOrderAdd

Adds one PurchaseOrder to the QBPOS company.
       

defMacro

You use a macro in a request message set if you need to create some object in one request, then refer to it in a subsequent request within that same message set. For example, you could create an inventory item and then include that item as a line item in a sales order all in one request message set, rather than create the item, query for it, then include it in a separate SalesOrderAdd request. In this latter case, you are accessing QBPOS three times, versus only once, using macros. The item to be referenced is specified via the defmacro. The actual reference to that item in the succeeding request is done via the use macro, as follows: ItemInventoryAdd defMacro=”ListID:Inv1” In the above line, you simply replace Inv1 with the name you want to give the macro. When you reference this macro in another request (one that requires that object’s listID) in the same message set, you use this syntax: ListID useMacro=”ListID:Inv1” This is covered in more detail in the Programming Guide.
IQBStringType   2.0  

Associate

The employee making the adjustment transaction.
IQBStringType 40 chars    

CancelDate

Enter the date after which delivery may be refused. If the company preferences for receiving are set to check for cancel dates, the end user is alerted when receiving items against a PO past this cancel date. (That user can still accept the shipment at the user’s discretion.) If the company preferences for receiving are not set to check the Cancel date, the Cancel date is ignored.
IQBDateType      

Discount

Discount amount: Enter the amount of any discount applicable to the PO. Discounts are applied to the PO subtotal. Entering an amount causes the Disc % field to be automatically calculated.
IQBAmountType      

DiscountPercent

Enter a percentage discount applicable to the PO. Discounts are applied to the PO subtotal. Entering a discount percentage causes the Disc $ field to be automatically calculated.
IQBFloatType      

Fee

You can enter a fee using this field. Notice that Fees entered on a PO (such as a special handling fee) are not spread over the cost of individual items. When a receiving voucher references a PO with a fee entered, the fee can be transferred to the voucher at that point.
IQBAmountType      

Instructions

You can use this optional field to provide instructions to the vendor regarding the order. You can add up to two lines of text. This text prints on PurchaseOrders, but are not displayed on-screen.
IQBStringType 2000 chars    

PurchaseOrderNumber

The number you want to assign to the purchase order. It should be unique. This number is automatically assigned to the PurchaseOrder by QBPOS if left empty during the creation process. An example of setting PO numbers is when you create a PO from a SalesOrder. You can use the SalesOrder number prefaced by PO, to show in the PO number the linkage between the sales order and the purchase order.
IQBStringType 20 chars    

PurchaseOrderStatusDesc

All PurchaseOrders have the status of either Open, Closed, or Custom. The Custom status is defined by the QBPOS user in Company Preferences for Purchasing. It has a user-specified description field.
IQBStringType      

ShipToStoreNumber

The store to which the item is to be shipped.
IQBIntType   2.0  

StartShipDate

PO Ship Date: Enter the estimated shipping date for the order. Included on purchase journal and merchandise on-order reports.
IQBDateType      

StoreNumber

This is used only for multi-store versions of QBPOS. The value is between 1 and 10, since a maximum of 10 stores are currently supported.
IQBIntType      

TermsDiscount

The TermsDiscount field specifies the discount percentage. A discount is applied by the vendor if payment is received on or before the number of days specified in the TermsDiscountDays field for that vendor. Terms-related discounts for vendors are created or modified in the VendorAdd/VendorMod fields TermsDiscountDays and TermsDiscount.
IQBFloatType   1.1  

TermsDiscountDays

The TermsDiscountDays field specifies the number of days after the invoice date in which payment must be received in order to obtain the discount percentage. A discount is applied by the vendor if payment is received on or before the number of days specified in the TermsDiscountDays field for that vendor. Terms-related discounts for vendors are created or modified in the VendorAdd/VendorMod fields TermsDiscountDays and TermsDiscount.
IQBIntType   1.1  

TermsNetDays

This establishes the vendor’s payment due date, which is based on the vendor’s invoice date. The due date is established by the number of days specified in this field after the invoice date. Payment must be made within this number of days.
IQBIntType   1.1  

TxnDate

The date of the transaction. In some cases, if you leave TxnDate out of an -Add message, QuickBooks will prefill TxnDate with the date of the last-saved transaction of the same type.
IQBDateType      

VendorListID

The listID of the vendor being referenced in this object reference.
IQBIDType     Y

useMacro

You use a macro in a request message set if you need to create some object in one request, then refer to it in a subsequent request within that same message set. For example, you could create an inventory item and then include that item as a line item in a sales order all in one request message set, rather than create the item, query for it, then include it in a separate SalesOrderAdd request. In this latter case, you are accessing QBPOS three times, versus only once, using macros. The item to be referenced is specified via the defmacro. The actual reference to that item in the succeeding request is done via the use macro, as follows: ItemInventoryAdd defMacro=”ListID:Inv1” In the above line, you simply replace Inv1 with the name you want to give the macro. When you reference this macro in another request (one that requires that object’s listID) in the same message set, you use this syntax: ListID useMacro=”ListID:Inv1” This is covered in more detail in the Programming Guide.
IQBStringType   2.0  

PurchaseOrderItemAddList

The list of PurchaseOrder line item objects returned in the response.
IPurchaseOrderItemAddList      

(List of IPurchaseOrderItemAdd Objects)

       

ListID

The unique ID returned by QBPOS for this object. If supplied in a request, the ListID is a reference to an object required in the request. For example, in a SalesOrder or PurchaseOrder line item, the ListID that is required is an Item list ID.
IQBIDType     Y

useMacro

You use a macro in a request message set if you need to create some object in one request, then refer to it in a subsequent request within that same message set. For example, you could create an inventory item and then include that item as a line item in a sales order all in one request message set, rather than create the item, query for it, then include it in a separate SalesOrderAdd request. In this latter case, you are accessing QBPOS three times, versus only once, using macros. The item to be referenced is specified via the defmacro. The actual reference to that item in the succeeding request is done via the use macro, as follows: ItemInventoryAdd defMacro=”ListID:Inv1” In the above line, you simply replace Inv1 with the name you want to give the macro. When you reference this macro in another request (one that requires that object’s listID) in the same message set, you use this syntax: ListID useMacro=”ListID:Inv1” This is covered in more detail in the Programming Guide.
IQBStringType   2.0  

ALU

Alternate Lookup. A user-defined identifier to be used to look up an item. Typically, this field contains such as the manufacturer’s part number, but it can contain any text descriptions, catalog numbers, etc. Duplicate Alternate Lookups are not allowed. Do not duplicate the Item # or UPC in this field. This will adversely affect performance for item lookups.
IQBStringType 20 chars    

Attribute

A field used to describe an item characteristic, typically color, pattern, material, or a second size. One to eight characters.
IQBStringType 12 chars    

Cost

The average cost of the item. Cost is automatically updated by receiving vouchers or manually updated by adjustment memos.
IQBAmountType      

Desc1

The principal item description field. This description is printed on receipts. For some versions of QBPOS, (Pro), this must be the same for all members of a style. Changes to this field can be applied to an item or to an entire style.
IQBStringType 30 chars    

Desc2

Secondary description field usually used for any additional information to describe this particular item, such as a vendor’s catalog number. Also can be used for additional information at the point of sale.
IQBStringType      

ExtendedCost

For a line item, Extended cost is the quantity ordered multiplied by the item cost.
IQBAmountType      

Qty

The quantity of the line item being ordered or transferred.
IQBQuanType      

Size

The size of an item; 1 to 8 characters. This field can also be used to describe a second item attribute other than size if desired.
IQBStringType 12 chars    

UnitOfMeasure

If the company is using only a single unit of measure, this specifies the unit of measure for the item. If the company is using multiple units of measure, this specifies the base unit of measure for the item. Inventory quantities are tracked and reported in terms of this base unit.
IQBStringType 20 chars 2.0  

UPC

Universal Product Code. The item’s unique UPC/EAN/ISBN identifier. This field must be 13 characters. If a shorter number is entered, QBPOS uses an appropriate algorithm to lengthen the entry to fill the 13-character field.
IQBStringType 18 chars    

IncludeRetElementList

You can use the IncludeRetElement feature to restrict the data returned in the response to the specified qbposXML field here. If you do this, only those elements specified will be returned. To use this feature, you simply add the qbposXML element name to the IncludeRetElementList. The following example shows how to do this, specifying that only the CreatedBy and ClockOutTime elements are to be returned in the TimeEntryAdd response: Dim MyTimeEntry As ITimeEntryAdd Set MyTimeEntry = requestMsgSet.AppendTimeEntryAddRq MyTimeEntry.IncludeRetElementList.Add “CreatedBy” MyTimeEntry.IncludeRetElementList.Add “ClockOutTime” ‘ set the other properties as desired…
IBSTRList 50 chars 2.0  
Tag Type Max length Implementation Required

IResponse

Adds one PurchaseOrder to the QBPOS company.
       

StatusCode

A number that corresponds to a statusSeverity and statusMessage. Five status codes relate directly to signon messages: 2000, 2010, 2020, 2030, and 2040. For details about these and other statusCode values that can be returned, see the statusCode table on the Error Codes page.
IQBIntType     Y

StatusSeverity

One of the following values: INFO The request was completed, and the results are consistent with what your application expected. WARNING The request was completed, but the results might not be consistent with what you expected. ERROR The request was not completed. No data will appear in the server’s response after the statusMessage.
IQBStringType     Y

StatusMessage

A user-readable explanation of the success or error condition that is indicated by the statusCode. For details about the statusMessage values that can be returned, see the “Explanation” column of the statusCode table on the Error Codes page.
IQBStringType     Y

Detail

IPurchaseOrderRet      

TxnID

QuickBooks generates a unique TxnID for each transaction that is added to QuickBooks. A TxnID returned from a request can be used to refer to the transaction in subsequent requests. Notice that you cannot supply the TxnID of a TimeTracking transaction to TransactionQueryRq requests. If you do, you get an error stating that no such record could be found, even though the transaction is in QuickBooks. This behavior reflects the behavior in the QuicKBooks UI in the Find window.
IQBIDType      

TimeCreated

The timestamp indicating the time when this object was created in QBPOS.
IQBDateTimeType   1.1  

TimeModified

The time when the object was modified by QBPOS.
IQBDateTimeType      

Associate

The employee making the adjustment transaction.
IQBStringType 40 chars    

CancelDate

Enter the date after which delivery may be refused. If the company preferences for receiving are set to check for cancel dates, the end user is alerted when receiving items against a PO past this cancel date. (That user can still accept the shipment at the user’s discretion.) If the company preferences for receiving are not set to check the Cancel date, the Cancel date is ignored.
IQBDateType      

CompanyName

The name of the business.
IQBStringType 41 chars    

Discount

Discount amount: Enter the amount of any discount applicable to the PO. Discounts are applied to the PO subtotal. Entering an amount causes the Disc % field to be automatically calculated.
IQBAmountType      

DiscountPercent

Enter a percentage discount applicable to the PO. Discounts are applied to the PO subtotal. Entering a discount percentage causes the Disc $ field to be automatically calculated.
IQBFloatType      

Fee

You can enter a fee using this field. Notice that Fees entered on a PO (such as a special handling fee) are not spread over the cost of individual items. When a receiving voucher references a PO with a fee entered, the fee can be transferred to the voucher at that point.
IQBAmountType      

Instructions

You can use this optional field to provide instructions to the vendor regarding the order. You can add up to two lines of text. This text prints on PurchaseOrders, but are not displayed on-screen.
IQBStringType 2000 chars    

ItemsCount

The number of line items in the adjustment add request that added the adjustment to QBPOS.
IQBIntType      

PurchaseOrderNumber

The number you want to assign to the purchase order. It should be unique. This number is automatically assigned to the PurchaseOrder by QBPOS if left empty during the creation process. An example of setting PO numbers is when you create a PO from a SalesOrder. You can use the SalesOrder number prefaced by PO, to show in the PO number the linkage between the sales order and the purchase order.
IQBStringType 20 chars    

PurchaseOrderStatusDesc

All PurchaseOrders have the status of either Open, Closed, or Custom. The Custom status is defined by the QBPOS user in Company Preferences for Purchasing. It has a user-specified description field.
IQBStringType      

QtyDue

In PO Item List: The item quantity remaining to be received.In PO Totals and PO List: The total document quantity remaining to be received. Updated by receiving vouchers. Qty Due = Qty Ordered – Qty Received.
IQBQuanType      

QtyOrdered

PO Totals and PO list: The total PO quantity ordered, combined for all items.
IQBQuanType      

QtyReceived

The quantity of the PurchaseOrder line item received to date. In PO Item List: The item quantity received to date.In PO Totals and PO List: The total document quantity received to date.
IQBQuanType      

SalesOrderNumber

This is a unique number automatically assigned to the SalesOrder at creation time by QBPOS. If a SalesOrder was used to generate a PurchaseOrder, the SalesOrderNumber is returned in the PurchaseOrder Ret object.
IQBStringType 32 chars    

ShipToStoreNumber

The store to which the item is to be shipped.
IQBIntType   2.0  

StartShipDate

PO Ship Date: Enter the estimated shipping date for the order. Included on purchase journal and merchandise on-order reports.
IQBDateType      

StoreExchangeStatus

In multi store configurations, if the customer’s information has changed, this information is updated at the headquarters store. This response field indicates whether the information was successfully updated or not.
IQBENStoreExchangeStatusType      

StoreNumber

This is used only for multi-store versions of QBPOS. The value is between 1 and 10, since a maximum of 10 stores are currently supported.
IQBIntType      

Subtotal

The total cost (sum of extended item costs) of the PO before applying any discounts or fees. This value is updated when a voucher that references the PO is updated.
IQBAmountType      

Terms

While not visible on the PO, any payment terms that are defined for the vendor file are carried to the PO and are available in this field in the returned PO object.
IQBStringType      

TermsDiscount

The TermsDiscount field specifies the discount percentage. A discount is applied by the vendor if payment is received on or before the number of days specified in the TermsDiscountDays field for that vendor. Terms-related discounts for vendors are created or modified in the VendorAdd/VendorMod fields TermsDiscountDays and TermsDiscount.
IQBFloatType   1.1  

TermsDiscountDays

The TermsDiscountDays field specifies the number of days after the invoice date in which payment must be received in order to obtain the discount percentage. A discount is applied by the vendor if payment is received on or before the number of days specified in the TermsDiscountDays field for that vendor. Terms-related discounts for vendors are created or modified in the VendorAdd/VendorMod fields TermsDiscountDays and TermsDiscount.
IQBIntType   1.1  

TermsNetDays

This establishes the vendor’s payment due date, which is based on the vendor’s invoice date. The due date is established by the number of days specified in this field after the invoice date. Payment must be made within this number of days.
IQBIntType   1.1  

Total

The total PO amount after discounts and fees are applied.Total = Subtotal - Disc $ + Fee This value is updated when a voucher that references the PO is updated.
IQBAmountType      

TxnDate

The date of the transaction. In some cases, if you leave TxnDate out of an -Add message, QuickBooks will prefill TxnDate with the date of the last-saved transaction of the same type.
IQBDateType      

UnfilledPercent

The percentage of the total PO quantity that has not yet been received. This value is updated when a voucher that references the PO is updated.
IQBFloatType      

VendorCode

The code assigned to the vendor specified for the item.
IQBStringType 3 chars    

VendorListID

The listID of the vendor being referenced in this object reference.
IQBIDType      

PurchaseOrderItemRetList

The list of PurchaseOrder line item objects returned in the response.
IPurchaseOrderItemRetList      

(List of IPurchaseOrderItemRet Objects)

       

ListID

The unique ID returned by QBPOS for this object. If supplied in a request, the ListID is a reference to an object required in the request. For example, in a SalesOrder or PurchaseOrder line item, the ListID that is required is an Item list ID.
IQBIDType      

TxnLineID

Identification number of the transaction line. (TxnLineID is supported as of v2.0 of the SDK. With qbXML v1.0 and v1.1, TxnLineID is always returned as zero.) If you need to add a new transaction line in a transaction Mod request, you can do so by setting the TxnLineID to -1.
IQBIntType      

ALU

Alternate Lookup. A user-defined identifier to be used to look up an item. Typically, this field contains such as the manufacturer’s part number, but it can contain any text descriptions, catalog numbers, etc. Duplicate Alternate Lookups are not allowed. Do not duplicate the Item # or UPC in this field. This will adversely affect performance for item lookups.
IQBStringType 20 chars    

Attribute

A field used to describe an item characteristic, typically color, pattern, material, or a second size. One to eight characters.
IQBStringType 12 chars    

Cost

The average cost of the item. Cost is automatically updated by receiving vouchers or manually updated by adjustment memos.
IQBAmountType      

Desc1

The principal item description field. This description is printed on receipts. For some versions of QBPOS, (Pro), this must be the same for all members of a style. Changes to this field can be applied to an item or to an entire style.
IQBStringType 30 chars    

Desc2

Secondary description field usually used for any additional information to describe this particular item, such as a vendor’s catalog number. Also can be used for additional information at the point of sale.
IQBStringType      

ExtendedCost

For a line item, Extended cost is the quantity ordered multiplied by the item cost.
IQBAmountType      

ItemNumber

Unique number assigned to the item when it is added to QBPOS.
IQBIntType      

NumberOfBaseUnits

If you use multiple units of measure, rather than a single UOM, you need to select one of the UOMs as the base unit. This base unit should be the smallest unit that you sell by. Inventory quantities are always expressed in terms of this base unit.
IQBQuanType   2.0  

Qty

The quantity of the line item being ordered or transferred.
IQBQuanType      

QtyReceived

The quantity of the PurchaseOrder line item received to date. In PO Item List: The item quantity received to date.In PO Totals and PO List: The total document quantity received to date.
IQBQuanType      

Size

The size of an item; 1 to 8 characters. This field can also be used to describe a second item attribute other than size if desired.
IQBStringType 12 chars    

UnitOfMeasure

If the company is using only a single unit of measure, this specifies the unit of measure for the item. If the company is using multiple units of measure, this specifies the base unit of measure for the item. Inventory quantities are tracked and reported in terms of this base unit.
IQBStringType 20 chars 2.0  

UPC

Universal Product Code. The item’s unique UPC/EAN/ISBN identifier. This field must be 13 characters. If a shorter number is entered, QBPOS uses an appropriate algorithm to lengthen the entry to fill the 13-character field.
IQBStringType 18 chars    

DataExtRetList

If you specify any custom fields/private data extensions to be returned in the query request (in the OwnerIDList), then this Ret List will contain all of the data extensions that belong to each specified OwnerID. For example, if you specify an OwnerID value of 0 (custom fields), then the query will return all custom data for the returned records.
IDataExtRetList   1.2  

(List of IDataExtRet Objects)

       

OwnerID

OwnerID refers to the owner of a data extension, and must be 0 or a valid GUID. (Custom fields, which are visible in the QuickBooks UI, always have an OwnerID of 0. ) Usually you would keep your application’s GUID confidential to prevent other applications from accessing your data extensions. But if you want to share data extensions with another application, the applications need to use the same GUID. In this case, each application could use two GUIDs, one for shared data extensions and one for confidential data extensions. (An application can have any number of GUIDs.) When you share a data extension with another application, the other application must know both the OwnerID and the DataExtName, as these together form a data extension’s unique name.
IQBGUIDType     Y

DataExtName

The name of the data extension. If this is a custom field, DataExtName will be visible as a label in the QuickBooks user interface. Also because OwnerID and DataExtName together make the data extension unique, and because custom fields all have the same OwnerID of zero, the DataExtName must be a unique value among existing custom fields. In contrast, the DataExtName for private data extensions must be unique only for the specified OwnerID GUID.
IQBStringType     Y

DataExtType

b>DataExtType The type of the data extension.
IQBENDataExtTypeType     Y

DataExtValue

The data in this field. The maximum length of DataExtValue will depend on the DataExtType of this data extension. For example, if DataExtType is STR255TYPE, the maximum length of DataExtValue is 255 characters. If DataExtType is STR1024TYPE, the maximum size of DataExtValue is 1KB.
IQBStringType     Y

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
<?xml version="1.0" encoding="utf-8"?>
<?qbposxml version="4.0"?>
<QBPOSXML>
        <QBPOSXMLMsgsRq onError="stopOnError">
                <PurchaseOrderAddRq>
                        <PurchaseOrderAdd defMacro="MACROTYPE"> <!-- required -->
                                <Associate >STRTYPE</Associate> <!-- optional -->
                                <CancelDate >DATETYPE</CancelDate> <!-- optional -->
                                <Discount >AMTTYPE</Discount> <!-- optional -->
                                <DiscountPercent >FLOATTYPE</DiscountPercent> <!-- optional -->
                                <Fee >AMTTYPE</Fee> <!-- optional -->
                                <Instructions >STRTYPE</Instructions> <!-- optional -->
                                <PurchaseOrderNumber >STRTYPE</PurchaseOrderNumber> <!-- optional -->
                                <PurchaseOrderStatusDesc >STRTYPE</PurchaseOrderStatusDesc> <!-- optional -->
                                <ShipToStoreNumber >INTTYPE</ShipToStoreNumber> <!-- optional -->
                                <StartShipDate >DATETYPE</StartShipDate> <!-- optional -->
                                <StoreNumber >INTTYPE</StoreNumber> <!-- optional -->
                                <TermsDiscount >FLOATTYPE</TermsDiscount> <!-- optional -->
                                <TermsDiscountDays >INTTYPE</TermsDiscountDays> <!-- optional -->
                                <TermsNetDays >INTTYPE</TermsNetDays> <!-- optional -->
                                <TxnDate >DATETYPE</TxnDate> <!-- optional -->
                                <VendorListID  useMacro="MACROTYPE">IDTYPE</VendorListID> <!-- required -->
                                <PurchaseOrderItemAdd> <!-- optional, may repeat -->
                                        <ListID  useMacro="MACROTYPE">IDTYPE</ListID> <!-- required -->
                                        <ALU >STRTYPE</ALU> <!-- optional -->
                                        <Attribute >STRTYPE</Attribute> <!-- optional -->
                                        <Cost >AMTTYPE</Cost> <!-- optional -->
                                        <Desc1 >STRTYPE</Desc1> <!-- optional -->
                                        <Desc2 >STRTYPE</Desc2> <!-- optional -->
                                        <ExtendedCost >AMTTYPE</ExtendedCost> <!-- optional -->
                                        <Qty >QUANTYPE</Qty> <!-- optional -->
                                        <Size >STRTYPE</Size> <!-- optional -->
                                        <UnitOfMeasure >STRTYPE</UnitOfMeasure> <!-- optional -->
                                        <UPC >STRTYPE</UPC> <!-- optional -->
                                </PurchaseOrderItemAdd>
                        </PurchaseOrderAdd>
                        <IncludeRetElement >STRTYPE</IncludeRetElement> <!-- optional, may repeat -->
                </PurchaseOrderAddRq>

                <PurchaseOrderAddRs statusCode="INTTYPE" statusSeverity="STRTYPE" statusMessage="STRTYPE">
                        <PurchaseOrderRet> <!-- optional -->
                                <TxnID >IDTYPE</TxnID> <!-- optional -->
                                <TimeCreated >DATETIMETYPE</TimeCreated> <!-- optional -->
                                <TimeModified >DATETIMETYPE</TimeModified> <!-- optional -->
                                <Associate >STRTYPE</Associate> <!-- optional -->
                                <CancelDate >DATETYPE</CancelDate> <!-- optional -->
                                <CompanyName >STRTYPE</CompanyName> <!-- optional -->
                                <Discount >AMTTYPE</Discount> <!-- optional -->
                                <DiscountPercent >FLOATTYPE</DiscountPercent> <!-- optional -->
                                <Fee >AMTTYPE</Fee> <!-- optional -->
                                <Instructions >STRTYPE</Instructions> <!-- optional -->
                                <ItemsCount >INTTYPE</ItemsCount> <!-- optional -->
                                <PurchaseOrderNumber >STRTYPE</PurchaseOrderNumber> <!-- optional -->
                                <PurchaseOrderStatusDesc >STRTYPE</PurchaseOrderStatusDesc> <!-- optional -->
                                <QtyDue >QUANTYPE</QtyDue> <!-- optional -->
                                <QtyOrdered >QUANTYPE</QtyOrdered> <!-- optional -->
                                <QtyReceived >QUANTYPE</QtyReceived> <!-- optional -->
                                <SalesOrderNumber >STRTYPE</SalesOrderNumber> <!-- optional -->
                                <ShipToStoreNumber >INTTYPE</ShipToStoreNumber> <!-- optional -->
                                <StartShipDate >DATETYPE</StartShipDate> <!-- optional -->
                                <!-- StoreExchangeStatus may have one of the following values: Modified, Sent, Acknowledged -->
                                <StoreExchangeStatus >ENUMTYPE</StoreExchangeStatus> <!-- optional -->
                                <StoreNumber >INTTYPE</StoreNumber> <!-- optional -->
                                <Subtotal >AMTTYPE</Subtotal> <!-- optional -->
                                <Terms >STRTYPE</Terms> <!-- optional -->
                                <TermsDiscount >FLOATTYPE</TermsDiscount> <!-- optional -->
                                <TermsDiscountDays >INTTYPE</TermsDiscountDays> <!-- optional -->
                                <TermsNetDays >INTTYPE</TermsNetDays> <!-- optional -->
                                <Total >AMTTYPE</Total> <!-- optional -->
                                <TxnDate >DATETYPE</TxnDate> <!-- optional -->
                                <UnfilledPercent >FLOATTYPE</UnfilledPercent> <!-- optional -->
                                <VendorCode >STRTYPE</VendorCode> <!-- optional -->
                                <VendorListID >IDTYPE</VendorListID> <!-- optional -->
                                <PurchaseOrderItemRet> <!-- optional, may repeat -->
                                        <ListID >IDTYPE</ListID> <!-- optional -->
                                        <TxnLineID >INTTYPE</TxnLineID> <!-- optional -->
                                        <ALU >STRTYPE</ALU> <!-- optional -->
                                        <Attribute >STRTYPE</Attribute> <!-- optional -->
                                        <Cost >AMTTYPE</Cost> <!-- optional -->
                                        <Desc1 >STRTYPE</Desc1> <!-- optional -->
                                        <Desc2 >STRTYPE</Desc2> <!-- optional -->
                                        <ExtendedCost >AMTTYPE</ExtendedCost> <!-- optional -->
                                        <ItemNumber >INTTYPE</ItemNumber> <!-- optional -->
                                        <NumberOfBaseUnits >QUANTYPE</NumberOfBaseUnits> <!-- optional -->
                                        <Qty >QUANTYPE</Qty> <!-- optional -->
                                        <QtyReceived >QUANTYPE</QtyReceived> <!-- optional -->
                                        <Size >STRTYPE</Size> <!-- optional -->
                                        <UnitOfMeasure >STRTYPE</UnitOfMeasure> <!-- optional -->
                                        <UPC >STRTYPE</UPC> <!-- optional -->
                                </PurchaseOrderItemRet>
                                <DataExtRet> <!-- optional, may repeat -->
                                        <OwnerID >GUIDTYPE</OwnerID> <!-- required -->
                                        <DataExtName >STRTYPE</DataExtName> <!-- required -->
                                        <!-- DataExtType may have one of the following values: INTTYPE, AMTTYPE, PRICETYPE, QUANTYPE, PERCENTTYPE, DATETIMETYPE, STR255TYPE, STR1024TYPE -->
                                        <DataExtType >ENUMTYPE</DataExtType> <!-- required -->
                                        <DataExtValue >STRTYPE</DataExtValue> <!-- required -->
                                </DataExtRet>
                        </PurchaseOrderRet>
                </PurchaseOrderAddRs>
        </QBPOSXMLMsgsRq>
</QBPOSXML>

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
'The following sample code is generated as an illustration of
'Creating requests and parsing responses ONLY
'This code is NOT intended to show best practices or ideal code
'Use at your most careful discretion

imports System
imports System.Net
imports System.Drawing
imports System.Collections
imports System.ComponentModel
imports System.Windows.Forms
imports System.Data
imports System.IO
imports Interop.qbposfc4

        Public Class SamplePurchaseOrderAdd
                Public Sub  DoPurchaseOrderAdd()
                        Dim sessionBegun as Boolean
                        sessionBegun = False
                        Dim connectionOpen as Boolean
                        connectionOpen = False
                        Dim sessionManager as QBPOSSessionManager
                        sessionManager = nothing

                        Try
                                'Create the session Manager object
                                sessionManager = new QBPOSSessionManager

                                'Create the message set request object to hold our request
                                Dim requestMsgSet as IMsgSetRequest
                                requestMsgSet = sessionManager.CreateMsgSetRequest(4,0)
                                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue

                                BuildPurchaseOrderAddRq(requestMsgSet)

                                'Connect to QuickBooks and begin a session
                                sessionManager.OpenConnection("","Sample Code from OSR")
                                connectionOpen = True
                                sessionManager.BeginSession("")
                                sessionBegun = True

                                'Send the request and get the response from QuickBooks
                                Dim responseMsgSet as IMsgSetResponse
                                responseMsgSet = sessionManager.DoRequests(requestMsgSet)

                                'End the session and close the connection to QuickBooks
                                sessionManager.EndSession()
                                sessionBegun = False
                                sessionManager.CloseConnection()
                                connectionOpen = False

                                WalkPurchaseOrderAddRs(responseMsgSet)
                        Catch e as Exception
                                MessageBox.Show(e.Message, "Error")
                                if (sessionBegun) then
                                        sessionManager.EndSession()
                                End If
                                if (connectionOpen) then
                                        sessionManager.CloseConnection()
                                End If
                        End Try
                End Sub
                Public Sub BuildPurchaseOrderAddRq(requestMsgSet as IMsgSetRequest)
                        Dim PurchaseOrderAddRq as IPurchaseOrderAdd
                        PurchaseOrderAddRq= requestMsgSet.AppendPurchaseOrderAddRq()
                        'Set field value for Associate
                        PurchaseOrderAddRq.Associate.SetValue("ab")
                        'Set field value for CancelDate
                        PurchaseOrderAddRq.CancelDate.SetValue(DateTime.Parse("12/15/2007"))
                        'Set field value for Discount
                        PurchaseOrderAddRq.Discount.SetValue(10.01)
                        'Set field value for DiscountPercent
                        PurchaseOrderAddRq.DiscountPercent.SetValue(12.34)
                        'Set field value for Fee
                        PurchaseOrderAddRq.Fee.SetValue(10.01)
                        'Set field value for Instructions
                        PurchaseOrderAddRq.Instructions.SetValue("ab")
                        'Set field value for PurchaseOrderNumber
                        PurchaseOrderAddRq.PurchaseOrderNumber.SetValue("ab")
                        'Set field value for PurchaseOrderStatusDesc
                        PurchaseOrderAddRq.PurchaseOrderStatusDesc.SetValue("ab")
                        'Set field value for ShipToStoreNumber
                        PurchaseOrderAddRq.ShipToStoreNumber.SetValue(6)
                        'Set field value for StartShipDate
                        PurchaseOrderAddRq.StartShipDate.SetValue(DateTime.Parse("12/15/2007"))
                        'Set field value for StoreNumber
                        PurchaseOrderAddRq.StoreNumber.SetValue(6)
                        'Set field value for TermsDiscount
                        PurchaseOrderAddRq.TermsDiscount.SetValue(12.34)
                        'Set field value for TermsDiscountDays
                        PurchaseOrderAddRq.TermsDiscountDays.SetValue(6)
                        'Set field value for TermsNetDays
                        PurchaseOrderAddRq.TermsNetDays.SetValue(6)
                        'Set field value for TxnDate
                        PurchaseOrderAddRq.TxnDate.SetValue(DateTime.Parse("12/15/2007"))
                        'Set field value for VendorListID
                        PurchaseOrderAddRq.VendorListID.SetValue("200000-1011023419")
                        'Set attributes
                        'Set field value for VendorListID to use Macro
                        PurchaseOrderAddRq.VendorListID.SetValueUseMacro("200000-1011023419")
                        Dim PurchaseOrderItemAdd2649 as IPurchaseOrderItemAdd
                        PurchaseOrderItemAdd2649=PurchaseOrderAddRq.PurchaseOrderItemAddList.Append()
                        'Set field value for ListID
                        PurchaseOrderItemAdd2649.ListID.SetValue("200000-1011023419")
                        'Set attributes
                        'Set field value for ListID to use Macro
                        PurchaseOrderItemAdd2649.ListID.SetValueUseMacro("200000-1011023419")
                        'Set field value for ALU
                        PurchaseOrderItemAdd2649.ALU.SetValue("ab")
                        'Set field value for Attribute
                        PurchaseOrderItemAdd2649.Attribute.SetValue("ab")
                        'Set field value for Cost
                        PurchaseOrderItemAdd2649.Cost.SetValue(10.01)
                        'Set field value for Desc1
                        PurchaseOrderItemAdd2649.Desc1.SetValue("ab")
                        'Set field value for Desc2
                        PurchaseOrderItemAdd2649.Desc2.SetValue("ab")
                        'Set field value for ExtendedCost
                        PurchaseOrderItemAdd2649.ExtendedCost.SetValue(10.01)
                        'Set field value for Qty
                        PurchaseOrderItemAdd2649.Qty.SetValue(2)
                        'Set field value for Size
                        PurchaseOrderItemAdd2649.Size.SetValue("ab")
                        'Set field value for UnitOfMeasure
                        PurchaseOrderItemAdd2649.UnitOfMeasure.SetValue("ab")
                        'Set field value for UPC
                        PurchaseOrderItemAdd2649.UPC.SetValue("ab")
                        'Set field value for IncludeRetElementList
                        'May create more than one of these if needed
                        PurchaseOrderAddRq.IncludeRetElementList.Add("ab")
                End Sub




                Public Sub WalkPurchaseOrderAddRs( responseMsgSet as IMsgSetResponse)
                        if (responseMsgSet is nothing) then
                                Exit Sub
                        End If

                        Dim responseList as IResponseList
                        responseList = responseMsgSet.ResponseList
                        if (responseList is nothing) then
                                Exit Sub
                        End If

                        'if we sent only one request, there is only one response, we'll walk the list for this sample
                        for j=0 to responseList.Count-1
                                Dim response as IResponse
                                response = responseList.GetAt(j)
                                'check the status code of the response, 0=ok, >0 is warning
                                if (response.StatusCode >= 0) then
                                        'the request-specific response is in the details, make sure we have some
                                        if (not response.Detail is nothing) then
                                                'make sure the response is the type we're expecting
                                                Dim responseType as ENResponseType
                                                responseType = CType(response.Type.GetValue(),ENResponseType)
                                                if (responseType = ENResponseType.rtPurchaseOrderAddRs) then
                                                        'upcast to more specific type here, this is safe because we checked with response.Type check above
                                                        Dim PurchaseOrderRet as IPurchaseOrderRet
                                                        PurchaseOrderRet = CType(response.Detail,IPurchaseOrderRet)
                                                                WalkPurchaseOrderRet(PurchaseOrderRet)
                                                End If
                                        End If
                                End If
                        Next j
                End Sub




                Public Sub WalkPurchaseOrderRet(PurchaseOrderRet as IPurchaseOrderRet)
                        if (PurchaseOrderRet is nothing) then
                                Exit Sub
                        End If

                        'Go through all the elements of IPurchaseOrderRet
                        'Get value of TxnID
                        if ( not PurchaseOrderRet.TxnID is nothing) then
                                Dim TxnID2650 as String
                                TxnID2650 = PurchaseOrderRet.TxnID.GetValue()
                        End If
                        'Get value of TimeCreated
                        if ( not PurchaseOrderRet.TimeCreated is nothing) then
                                Dim TimeCreated2651 as DateTime
                                TimeCreated2651 = PurchaseOrderRet.TimeCreated.GetValue()
                        End If
                        'Get value of TimeModified
                        if ( not PurchaseOrderRet.TimeModified is nothing) then
                                Dim TimeModified2652 as DateTime
                                TimeModified2652 = PurchaseOrderRet.TimeModified.GetValue()
                        End If
                        'Get value of Associate
                        if ( not PurchaseOrderRet.Associate is nothing) then
                                Dim Associate2653 as String
                                Associate2653 = PurchaseOrderRet.Associate.GetValue()
                        End If
                        'Get value of CancelDate
                        if ( not PurchaseOrderRet.CancelDate is nothing) then
                                Dim CancelDate2654 as DateTime
                                CancelDate2654 = PurchaseOrderRet.CancelDate.GetValue()
                        End If
                        'Get value of CompanyName
                        if ( not PurchaseOrderRet.CompanyName is nothing) then
                                Dim CompanyName2655 as String
                                CompanyName2655 = PurchaseOrderRet.CompanyName.GetValue()
                        End If
                        'Get value of Discount
                        if ( not PurchaseOrderRet.Discount is nothing) then
                                Dim Discount2656 as Double
                                Discount2656 = PurchaseOrderRet.Discount.GetValue()
                        End If
                        'Get value of DiscountPercent
                        if ( not PurchaseOrderRet.DiscountPercent is nothing) then
                                Dim DiscountPercent2657 as Single
                                DiscountPercent2657 = PurchaseOrderRet.DiscountPercent.GetValue()
                        End If
                        'Get value of Fee
                        if ( not PurchaseOrderRet.Fee is nothing) then
                                Dim Fee2658 as Double
                                Fee2658 = PurchaseOrderRet.Fee.GetValue()
                        End If
                        'Get value of Instructions
                        if ( not PurchaseOrderRet.Instructions is nothing) then
                                Dim Instructions2659 as String
                                Instructions2659 = PurchaseOrderRet.Instructions.GetValue()
                        End If
                        'Get value of ItemsCount
                        if ( not PurchaseOrderRet.ItemsCount is nothing) then
                                Dim ItemsCount2660 as Integer
                                ItemsCount2660 = PurchaseOrderRet.ItemsCount.GetValue()
                        End If
                        'Get value of PurchaseOrderNumber
                        if ( not PurchaseOrderRet.PurchaseOrderNumber is nothing) then
                                Dim PurchaseOrderNumber2661 as String
                                PurchaseOrderNumber2661 = PurchaseOrderRet.PurchaseOrderNumber.GetValue()
                        End If
                        'Get value of PurchaseOrderStatusDesc
                        if ( not PurchaseOrderRet.PurchaseOrderStatusDesc is nothing) then
                                Dim PurchaseOrderStatusDesc2662 as String
                                PurchaseOrderStatusDesc2662 = PurchaseOrderRet.PurchaseOrderStatusDesc.GetValue()
                        End If
                        'Get value of QtyDue
                        if ( not PurchaseOrderRet.QtyDue is nothing) then
                                Dim QtyDue2663 as Double
                                QtyDue2663 = PurchaseOrderRet.QtyDue.GetValue()
                        End If
                        'Get value of QtyOrdered
                        if ( not PurchaseOrderRet.QtyOrdered is nothing) then
                                Dim QtyOrdered2664 as Double
                                QtyOrdered2664 = PurchaseOrderRet.QtyOrdered.GetValue()
                        End If
                        'Get value of QtyReceived
                        if ( not PurchaseOrderRet.QtyReceived is nothing) then
                                Dim QtyReceived2665 as Double
                                QtyReceived2665 = PurchaseOrderRet.QtyReceived.GetValue()
                        End If
                        'Get value of SalesOrderNumber
                        if ( not PurchaseOrderRet.SalesOrderNumber is nothing) then
                                Dim SalesOrderNumber2666 as String
                                SalesOrderNumber2666 = PurchaseOrderRet.SalesOrderNumber.GetValue()
                        End If
                        'Get value of ShipToStoreNumber
                        if ( not PurchaseOrderRet.ShipToStoreNumber is nothing) then
                                Dim ShipToStoreNumber2667 as Integer
                                ShipToStoreNumber2667 = PurchaseOrderRet.ShipToStoreNumber.GetValue()
                        End If
                        'Get value of StartShipDate
                        if ( not PurchaseOrderRet.StartShipDate is nothing) then
                                Dim StartShipDate2668 as DateTime
                                StartShipDate2668 = PurchaseOrderRet.StartShipDate.GetValue()
                        End If
                        'Get value of StoreExchangeStatus
                        if ( not PurchaseOrderRet.StoreExchangeStatus is nothing) then
                                Dim StoreExchangeStatus2669 as ENStoreExchangeStatus
                                StoreExchangeStatus2669 = PurchaseOrderRet.StoreExchangeStatus.GetValue()
                        End If
                        'Get value of StoreNumber
                        if ( not PurchaseOrderRet.StoreNumber is nothing) then
                                Dim StoreNumber2670 as Integer
                                StoreNumber2670 = PurchaseOrderRet.StoreNumber.GetValue()
                        End If
                        'Get value of Subtotal
                        if ( not PurchaseOrderRet.Subtotal is nothing) then
                                Dim Subtotal2671 as Double
                                Subtotal2671 = PurchaseOrderRet.Subtotal.GetValue()
                        End If
                        'Get value of Terms
                        if ( not PurchaseOrderRet.Terms is nothing) then
                                Dim Terms2672 as String
                                Terms2672 = PurchaseOrderRet.Terms.GetValue()
                        End If
                        'Get value of TermsDiscount
                        if ( not PurchaseOrderRet.TermsDiscount is nothing) then
                                Dim TermsDiscount2673 as Single
                                TermsDiscount2673 = PurchaseOrderRet.TermsDiscount.GetValue()
                        End If
                        'Get value of TermsDiscountDays
                        if ( not PurchaseOrderRet.TermsDiscountDays is nothing) then
                                Dim TermsDiscountDays2674 as Integer
                                TermsDiscountDays2674 = PurchaseOrderRet.TermsDiscountDays.GetValue()
                        End If
                        'Get value of TermsNetDays
                        if ( not PurchaseOrderRet.TermsNetDays is nothing) then
                                Dim TermsNetDays2675 as Integer
                                TermsNetDays2675 = PurchaseOrderRet.TermsNetDays.GetValue()
                        End If
                        'Get value of Total
                        if ( not PurchaseOrderRet.Total is nothing) then
                                Dim Total2676 as Double
                                Total2676 = PurchaseOrderRet.Total.GetValue()
                        End If
                        'Get value of TxnDate
                        if ( not PurchaseOrderRet.TxnDate is nothing) then
                                Dim TxnDate2677 as DateTime
                                TxnDate2677 = PurchaseOrderRet.TxnDate.GetValue()
                        End If
                        'Get value of UnfilledPercent
                        if ( not PurchaseOrderRet.UnfilledPercent is nothing) then
                                Dim UnfilledPercent2678 as Single
                                UnfilledPercent2678 = PurchaseOrderRet.UnfilledPercent.GetValue()
                        End If
                        'Get value of VendorCode
                        if ( not PurchaseOrderRet.VendorCode is nothing) then
                                Dim VendorCode2679 as String
                                VendorCode2679 = PurchaseOrderRet.VendorCode.GetValue()
                        End If
                        'Get value of VendorListID
                        if ( not PurchaseOrderRet.VendorListID is nothing) then
                                Dim VendorListID2680 as String
                                VendorListID2680 = PurchaseOrderRet.VendorListID.GetValue()
                        End If
                        if (not PurchaseOrderRet.PurchaseOrderItemRetList is nothing)
                                Dim i2681 as Integer
                                for i2681 = 0  to PurchaseOrderRet.PurchaseOrderItemRetList.Count - 1
                                        Dim PurchaseOrderItemRet as IPurchaseOrderItemRet
                                        PurchaseOrderItemRet = PurchaseOrderRet.PurchaseOrderItemRetList.GetAt(i2681)
                                        'Get value of ListID
                                        if ( not PurchaseOrderItemRet.ListID is nothing) then
                                                Dim ListID2682 as String
                                                ListID2682 = PurchaseOrderItemRet.ListID.GetValue()
                                        End If
                                        'Get value of TxnLineID
                                        if ( not PurchaseOrderItemRet.TxnLineID is nothing) then
                                                Dim TxnLineID2683 as Integer
                                                TxnLineID2683 = PurchaseOrderItemRet.TxnLineID.GetValue()
                                        End If
                                        'Get value of ALU
                                        if ( not PurchaseOrderItemRet.ALU is nothing) then
                                                Dim ALU2684 as String
                                                ALU2684 = PurchaseOrderItemRet.ALU.GetValue()
                                        End If
                                        'Get value of Attribute
                                        if ( not PurchaseOrderItemRet.Attribute is nothing) then
                                                Dim Attribute2685 as String
                                                Attribute2685 = PurchaseOrderItemRet.Attribute.GetValue()
                                        End If
                                        'Get value of Cost
                                        if ( not PurchaseOrderItemRet.Cost is nothing) then
                                                Dim Cost2686 as Double
                                                Cost2686 = PurchaseOrderItemRet.Cost.GetValue()
                                        End If
                                        'Get value of Desc1
                                        if ( not PurchaseOrderItemRet.Desc1 is nothing) then
                                                Dim Desc12687 as String
                                                Desc12687 = PurchaseOrderItemRet.Desc1.GetValue()
                                        End If
                                        'Get value of Desc2
                                        if ( not PurchaseOrderItemRet.Desc2 is nothing) then
                                                Dim Desc22688 as String
                                                Desc22688 = PurchaseOrderItemRet.Desc2.GetValue()
                                        End If
                                        'Get value of ExtendedCost
                                        if ( not PurchaseOrderItemRet.ExtendedCost is nothing) then
                                                Dim ExtendedCost2689 as Double
                                                ExtendedCost2689 = PurchaseOrderItemRet.ExtendedCost.GetValue()
                                        End If
                                        'Get value of ItemNumber
                                        if ( not PurchaseOrderItemRet.ItemNumber is nothing) then
                                                Dim ItemNumber2690 as Integer
                                                ItemNumber2690 = PurchaseOrderItemRet.ItemNumber.GetValue()
                                        End If
                                        'Get value of NumberOfBaseUnits
                                        if ( not PurchaseOrderItemRet.NumberOfBaseUnits is nothing) then
                                                Dim NumberOfBaseUnits2691 as Double
                                                NumberOfBaseUnits2691 = PurchaseOrderItemRet.NumberOfBaseUnits.GetValue()
                                        End If
                                        'Get value of Qty
                                        if ( not PurchaseOrderItemRet.Qty is nothing) then
                                                Dim Qty2692 as Double
                                                Qty2692 = PurchaseOrderItemRet.Qty.GetValue()
                                        End If
                                        'Get value of QtyReceived
                                        if ( not PurchaseOrderItemRet.QtyReceived is nothing) then
                                                Dim QtyReceived2693 as Double
                                                QtyReceived2693 = PurchaseOrderItemRet.QtyReceived.GetValue()
                                        End If
                                        'Get value of Size
                                        if ( not PurchaseOrderItemRet.Size is nothing) then
                                                Dim Size2694 as String
                                                Size2694 = PurchaseOrderItemRet.Size.GetValue()
                                        End If
                                        'Get value of UnitOfMeasure
                                        if ( not PurchaseOrderItemRet.UnitOfMeasure is nothing) then
                                                Dim UnitOfMeasure2695 as String
                                                UnitOfMeasure2695 = PurchaseOrderItemRet.UnitOfMeasure.GetValue()
                                        End If
                                        'Get value of UPC
                                        if ( not PurchaseOrderItemRet.UPC is nothing) then
                                                Dim UPC2696 as String
                                                UPC2696 = PurchaseOrderItemRet.UPC.GetValue()
                                        End If
                                Next i2681
                        End If
                        if (not PurchaseOrderRet.DataExtRetList is nothing)
                                Dim i2697 as Integer
                                for i2697 = 0  to PurchaseOrderRet.DataExtRetList.Count - 1
                                        Dim DataExtRet as IDataExtRet
                                        DataExtRet = PurchaseOrderRet.DataExtRetList.GetAt(i2697)
                                        'Get value of OwnerID
                                        Dim OwnerID2698 as String
                                        OwnerID2698 = DataExtRet.OwnerID.GetValue()
                                        'Get value of DataExtName
                                        Dim DataExtName2699 as String
                                        DataExtName2699 = DataExtRet.DataExtName.GetValue()
                                        'Get value of DataExtType
                                        Dim DataExtType2700 as ENDataExtType
                                        DataExtType2700 = DataExtRet.DataExtType.GetValue()
                                        'Get value of DataExtValue
                                        Dim DataExtValue2701 as String
                                        DataExtValue2701 = DataExtRet.DataExtValue.GetValue()
                                Next i2697
                        End If
                End Sub




        End Class

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
//The following sample code is generated as an illustration of
//Creating requests and parsing responses ONLY
//This code is NOT intended to show best practices or ideal code
//Use at your most careful discretion

using System;
using System.Net;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Interop.qbposfc4;

namespace com.intuit.idn.samples
{
        public class SamplePurchaseOrderAdd
        {
                public void  DoPurchaseOrderAdd()
                {
                        bool sessionBegun = false;
                        bool connectionOpen = false;
                        QBPOSSessionManager sessionManager = null;

                        try
                        {
                                //Create the session Manager object
                                sessionManager = new QBPOSSessionManager();

                                //Create the message set request object to hold our request
                                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest(4,0);
                                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                                BuildPurchaseOrderAddRq(requestMsgSet);

                                //Connect to QuickBooks and begin a session
                                sessionManager.OpenConnection("","Sample Code from OSR");
                                connectionOpen = true;
                                sessionManager.BeginSession("");
                                sessionBegun = true;

                                //Send the request and get the response from QuickBooks
                                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

                                //End the session and close the connection to QuickBooks
                                sessionManager.EndSession();
                                sessionBegun = false;
                                sessionManager.CloseConnection();
                                connectionOpen = false;

                                WalkPurchaseOrderAddRs(responseMsgSet);
                        }
                        catch (Exception e)
                        {
                                MessageBox.Show(e.Message, "Error");
                                if (sessionBegun)
                                {
                                        sessionManager.EndSession();
                                }
                                if (connectionOpen)
                                {
                                        sessionManager.CloseConnection();
                                }
                        }
                }
                void BuildPurchaseOrderAddRq(IMsgSetRequest requestMsgSet)
                {
                        IPurchaseOrderAdd PurchaseOrderAddRq= requestMsgSet.AppendPurchaseOrderAddRq();
                        //Set attributes
                        //Set field value for defMacro
                        PurchaseOrderAddRq.defMacro.SetValue("IQBStringType");
                        //Set field value for Associate
                        PurchaseOrderAddRq.Associate.SetValue("ab");
                        //Set field value for CancelDate
                        PurchaseOrderAddRq.CancelDate.SetValue(DateTime.Parse("12/15/2007"));
                        //Set field value for Discount
                        PurchaseOrderAddRq.Discount.SetValue(10.01);
                        //Set field value for DiscountPercent
                        PurchaseOrderAddRq.DiscountPercent.SetValue(12.34F);
                        //Set field value for Fee
                        PurchaseOrderAddRq.Fee.SetValue(10.01);
                        //Set field value for Instructions
                        PurchaseOrderAddRq.Instructions.SetValue("ab");
                        //Set field value for PurchaseOrderNumber
                        PurchaseOrderAddRq.PurchaseOrderNumber.SetValue("ab");
                        //Set field value for PurchaseOrderStatusDesc
                        PurchaseOrderAddRq.PurchaseOrderStatusDesc.SetValue("ab");
                        //Set field value for ShipToStoreNumber
                        PurchaseOrderAddRq.ShipToStoreNumber.SetValue(6);
                        //Set field value for StartShipDate
                        PurchaseOrderAddRq.StartShipDate.SetValue(DateTime.Parse("12/15/2007"));
                        //Set field value for StoreNumber
                        PurchaseOrderAddRq.StoreNumber.SetValue(6);
                        //Set field value for TermsDiscount
                        PurchaseOrderAddRq.TermsDiscount.SetValue(12.34F);
                        //Set field value for TermsDiscountDays
                        PurchaseOrderAddRq.TermsDiscountDays.SetValue(6);
                        //Set field value for TermsNetDays
                        PurchaseOrderAddRq.TermsNetDays.SetValue(6);
                        //Set field value for TxnDate
                        PurchaseOrderAddRq.TxnDate.SetValue(DateTime.Parse("12/15/2007"));
                        //Set field value for VendorListID
                        PurchaseOrderAddRq.VendorListID.SetValue("200000-1011023419");
                        //Set attributes
                        //Set field value for VendorListID to use Macro
                        PurchaseOrderAddRq.VendorListID.SetValueUseMacro("200000-1011023419");
                        IPurchaseOrderItemAdd PurchaseOrderItemAdd2702=PurchaseOrderAddRq.PurchaseOrderItemAddList.Append();
                        //Set field value for ListID
                        PurchaseOrderItemAdd2702.ListID.SetValue("200000-1011023419");
                        //Set attributes
                        //Set field value for ListID to use Macro
                        PurchaseOrderItemAdd2702.ListID.SetValueUseMacro("200000-1011023419");
                        //Set field value for ALU
                        PurchaseOrderItemAdd2702.ALU.SetValue("ab");
                        //Set field value for Attribute
                        PurchaseOrderItemAdd2702.Attribute.SetValue("ab");
                        //Set field value for Cost
                        PurchaseOrderItemAdd2702.Cost.SetValue(10.01);
                        //Set field value for Desc1
                        PurchaseOrderItemAdd2702.Desc1.SetValue("ab");
                        //Set field value for Desc2
                        PurchaseOrderItemAdd2702.Desc2.SetValue("ab");
                        //Set field value for ExtendedCost
                        PurchaseOrderItemAdd2702.ExtendedCost.SetValue(10.01);
                        //Set field value for Qty
                        PurchaseOrderItemAdd2702.Qty.SetValue(2);
                        //Set field value for Size
                        PurchaseOrderItemAdd2702.Size.SetValue("ab");
                        //Set field value for UnitOfMeasure
                        PurchaseOrderItemAdd2702.UnitOfMeasure.SetValue("ab");
                        //Set field value for UPC
                        PurchaseOrderItemAdd2702.UPC.SetValue("ab");
                        //Set field value for IncludeRetElementList
                        //May create more than one of these if needed
                        PurchaseOrderAddRq.IncludeRetElementList.Add("ab");
                }




                void WalkPurchaseOrderAddRs(IMsgSetResponse responseMsgSet)
                {
                        if (responseMsgSet == null) return;
                        IResponseList responseList = responseMsgSet.ResponseList;
                        if (responseList == null) return;
                        //if we sent only one request, there is only one response, we'll walk the list for this sample
                        for(int i=0; i < responseList.Count; i++)
                        {
                                IResponse response = responseList.GetAt(i);
                                //check the status code of the response, 0=ok, >0 is warning
                                if (response.StatusCode >= 0)
                                {
                                        //the request-specific response is in the details, make sure we have some
                                        if (response.Detail != null)
                                        {
                                                //make sure the response is the type we're expecting
                                                ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                                                if (responseType == ENResponseType.rtPurchaseOrderAddRs)
                                                {
                                                        //upcast to more specific type here, this is safe because we checked with response.Type check above
                                                        IPurchaseOrderRet PurchaseOrderRet = (IPurchaseOrderRet)response.Detail;
                                                                WalkPurchaseOrderRet(PurchaseOrderRet);
                                                }
                                        }
                                }
                        }
                }




                void WalkPurchaseOrderRet(IPurchaseOrderRet PurchaseOrderRet)
                {
                        if (PurchaseOrderRet == null) return;
                        //Go through all the elements of IPurchaseOrderRet
                        //Get value of TxnID
                        if (PurchaseOrderRet.TxnID != null)
                        {
                                string TxnID2703 = (string)PurchaseOrderRet.TxnID.GetValue();
                        }
                        //Get value of TimeCreated
                        if (PurchaseOrderRet.TimeCreated != null)
                        {
                                DateTime TimeCreated2704 = (DateTime)PurchaseOrderRet.TimeCreated.GetValue();
                        }
                        //Get value of TimeModified
                        if (PurchaseOrderRet.TimeModified != null)
                        {
                                DateTime TimeModified2705 = (DateTime)PurchaseOrderRet.TimeModified.GetValue();
                        }
                        //Get value of Associate
                        if (PurchaseOrderRet.Associate != null)
                        {
                                string Associate2706 = (string)PurchaseOrderRet.Associate.GetValue();
                        }
                        //Get value of CancelDate
                        if (PurchaseOrderRet.CancelDate != null)
                        {
                                DateTime CancelDate2707 = (DateTime)PurchaseOrderRet.CancelDate.GetValue();
                        }
                        //Get value of CompanyName
                        if (PurchaseOrderRet.CompanyName != null)
                        {
                                string CompanyName2708 = (string)PurchaseOrderRet.CompanyName.GetValue();
                        }
                        //Get value of Discount
                        if (PurchaseOrderRet.Discount != null)
                        {
                                double Discount2709 = (double)PurchaseOrderRet.Discount.GetValue();
                        }
                        //Get value of DiscountPercent
                        if (PurchaseOrderRet.DiscountPercent != null)
                        {
                                float DiscountPercent2710 = (float)PurchaseOrderRet.DiscountPercent.GetValue();
                        }
                        //Get value of Fee
                        if (PurchaseOrderRet.Fee != null)
                        {
                                double Fee2711 = (double)PurchaseOrderRet.Fee.GetValue();
                        }
                        //Get value of Instructions
                        if (PurchaseOrderRet.Instructions != null)
                        {
                                string Instructions2712 = (string)PurchaseOrderRet.Instructions.GetValue();
                        }
                        //Get value of ItemsCount
                        if (PurchaseOrderRet.ItemsCount != null)
                        {
                                int ItemsCount2713 = (int)PurchaseOrderRet.ItemsCount.GetValue();
                        }
                        //Get value of PurchaseOrderNumber
                        if (PurchaseOrderRet.PurchaseOrderNumber != null)
                        {
                                string PurchaseOrderNumber2714 = (string)PurchaseOrderRet.PurchaseOrderNumber.GetValue();
                        }
                        //Get value of PurchaseOrderStatusDesc
                        if (PurchaseOrderRet.PurchaseOrderStatusDesc != null)
                        {
                                string PurchaseOrderStatusDesc2715 = (string)PurchaseOrderRet.PurchaseOrderStatusDesc.GetValue();
                        }
                        //Get value of QtyDue
                        if (PurchaseOrderRet.QtyDue != null)
                        {
                                int QtyDue2716 = (int)PurchaseOrderRet.QtyDue.GetValue();
                        }
                        //Get value of QtyOrdered
                        if (PurchaseOrderRet.QtyOrdered != null)
                        {
                                int QtyOrdered2717 = (int)PurchaseOrderRet.QtyOrdered.GetValue();
                        }
                        //Get value of QtyReceived
                        if (PurchaseOrderRet.QtyReceived != null)
                        {
                                int QtyReceived2718 = (int)PurchaseOrderRet.QtyReceived.GetValue();
                        }
                        //Get value of SalesOrderNumber
                        if (PurchaseOrderRet.SalesOrderNumber != null)
                        {
                                string SalesOrderNumber2719 = (string)PurchaseOrderRet.SalesOrderNumber.GetValue();
                        }
                        //Get value of ShipToStoreNumber
                        if (PurchaseOrderRet.ShipToStoreNumber != null)
                        {
                                int ShipToStoreNumber2720 = (int)PurchaseOrderRet.ShipToStoreNumber.GetValue();
                        }
                        //Get value of StartShipDate
                        if (PurchaseOrderRet.StartShipDate != null)
                        {
                                DateTime StartShipDate2721 = (DateTime)PurchaseOrderRet.StartShipDate.GetValue();
                        }
                        //Get value of StoreExchangeStatus
                        if (PurchaseOrderRet.StoreExchangeStatus != null)
                        {
                                ENStoreExchangeStatus StoreExchangeStatus2722 = (ENStoreExchangeStatus)PurchaseOrderRet.StoreExchangeStatus.GetValue();
                        }
                        //Get value of StoreNumber
                        if (PurchaseOrderRet.StoreNumber != null)
                        {
                                int StoreNumber2723 = (int)PurchaseOrderRet.StoreNumber.GetValue();
                        }
                        //Get value of Subtotal
                        if (PurchaseOrderRet.Subtotal != null)
                        {
                                double Subtotal2724 = (double)PurchaseOrderRet.Subtotal.GetValue();
                        }
                        //Get value of Terms
                        if (PurchaseOrderRet.Terms != null)
                        {
                                string Terms2725 = (string)PurchaseOrderRet.Terms.GetValue();
                        }
                        //Get value of TermsDiscount
                        if (PurchaseOrderRet.TermsDiscount != null)
                        {
                                float TermsDiscount2726 = (float)PurchaseOrderRet.TermsDiscount.GetValue();
                        }
                        //Get value of TermsDiscountDays
                        if (PurchaseOrderRet.TermsDiscountDays != null)
                        {
                                int TermsDiscountDays2727 = (int)PurchaseOrderRet.TermsDiscountDays.GetValue();
                        }
                        //Get value of TermsNetDays
                        if (PurchaseOrderRet.TermsNetDays != null)
                        {
                                int TermsNetDays2728 = (int)PurchaseOrderRet.TermsNetDays.GetValue();
                        }
                        //Get value of Total
                        if (PurchaseOrderRet.Total != null)
                        {
                                double Total2729 = (double)PurchaseOrderRet.Total.GetValue();
                        }
                        //Get value of TxnDate
                        if (PurchaseOrderRet.TxnDate != null)
                        {
                                DateTime TxnDate2730 = (DateTime)PurchaseOrderRet.TxnDate.GetValue();
                        }
                        //Get value of UnfilledPercent
                        if (PurchaseOrderRet.UnfilledPercent != null)
                        {
                                float UnfilledPercent2731 = (float)PurchaseOrderRet.UnfilledPercent.GetValue();
                        }
                        //Get value of VendorCode
                        if (PurchaseOrderRet.VendorCode != null)
                        {
                                string VendorCode2732 = (string)PurchaseOrderRet.VendorCode.GetValue();
                        }
                        //Get value of VendorListID
                        if (PurchaseOrderRet.VendorListID != null)
                        {
                                string VendorListID2733 = (string)PurchaseOrderRet.VendorListID.GetValue();
                        }
                        if (PurchaseOrderRet.PurchaseOrderItemRetList != null)
                        {
                                for (int i2734 = 0; i2734 < PurchaseOrderRet.PurchaseOrderItemRetList.Count; i2734++)
                                {
                                        IPurchaseOrderItemRet PurchaseOrderItemRet = PurchaseOrderRet.PurchaseOrderItemRetList.GetAt(i2734);
                                        //Get value of ListID
                                        if (PurchaseOrderItemRet.ListID != null)
                                        {
                                                string ListID2735 = (string)PurchaseOrderItemRet.ListID.GetValue();
                                        }
                                        //Get value of TxnLineID
                                        if (PurchaseOrderItemRet.TxnLineID != null)
                                        {
                                                int TxnLineID2736 = (int)PurchaseOrderItemRet.TxnLineID.GetValue();
                                        }
                                        //Get value of ALU
                                        if (PurchaseOrderItemRet.ALU != null)
                                        {
                                                string ALU2737 = (string)PurchaseOrderItemRet.ALU.GetValue();
                                        }
                                        //Get value of Attribute
                                        if (PurchaseOrderItemRet.Attribute != null)
                                        {
                                                string Attribute2738 = (string)PurchaseOrderItemRet.Attribute.GetValue();
                                        }
                                        //Get value of Cost
                                        if (PurchaseOrderItemRet.Cost != null)
                                        {
                                                double Cost2739 = (double)PurchaseOrderItemRet.Cost.GetValue();
                                        }
                                        //Get value of Desc1
                                        if (PurchaseOrderItemRet.Desc1 != null)
                                        {
                                                string Desc12740 = (string)PurchaseOrderItemRet.Desc1.GetValue();
                                        }
                                        //Get value of Desc2
                                        if (PurchaseOrderItemRet.Desc2 != null)
                                        {
                                                string Desc22741 = (string)PurchaseOrderItemRet.Desc2.GetValue();
                                        }
                                        //Get value of ExtendedCost
                                        if (PurchaseOrderItemRet.ExtendedCost != null)
                                        {
                                                double ExtendedCost2742 = (double)PurchaseOrderItemRet.ExtendedCost.GetValue();
                                        }
                                        //Get value of ItemNumber
                                        if (PurchaseOrderItemRet.ItemNumber != null)
                                        {
                                                int ItemNumber2743 = (int)PurchaseOrderItemRet.ItemNumber.GetValue();
                                        }
                                        //Get value of NumberOfBaseUnits
                                        if (PurchaseOrderItemRet.NumberOfBaseUnits != null)
                                        {
                                                int NumberOfBaseUnits2744 = (int)PurchaseOrderItemRet.NumberOfBaseUnits.GetValue();
                                        }
                                        //Get value of Qty
                                        if (PurchaseOrderItemRet.Qty != null)
                                        {
                                                int Qty2745 = (int)PurchaseOrderItemRet.Qty.GetValue();
                                        }
                                        //Get value of QtyReceived
                                        if (PurchaseOrderItemRet.QtyReceived != null)
                                        {
                                                int QtyReceived2746 = (int)PurchaseOrderItemRet.QtyReceived.GetValue();
                                        }
                                        //Get value of Size
                                        if (PurchaseOrderItemRet.Size != null)
                                        {
                                                string Size2747 = (string)PurchaseOrderItemRet.Size.GetValue();
                                        }
                                        //Get value of UnitOfMeasure
                                        if (PurchaseOrderItemRet.UnitOfMeasure != null)
                                        {
                                                string UnitOfMeasure2748 = (string)PurchaseOrderItemRet.UnitOfMeasure.GetValue();
                                        }
                                        //Get value of UPC
                                        if (PurchaseOrderItemRet.UPC != null)
                                        {
                                                string UPC2749 = (string)PurchaseOrderItemRet.UPC.GetValue();
                                        }
                                }
                        }
                        if (PurchaseOrderRet.DataExtRetList != null)
                        {
                                for (int i2750 = 0; i2750 < PurchaseOrderRet.DataExtRetList.Count; i2750++)
                                {
                                        IDataExtRet DataExtRet = PurchaseOrderRet.DataExtRetList.GetAt(i2750);
                                        //Get value of OwnerID
                                        string OwnerID2751 = (string)DataExtRet.OwnerID.GetValue();
                                        //Get value of DataExtName
                                        string DataExtName2752 = (string)DataExtRet.DataExtName.GetValue();
                                        //Get value of DataExtType
                                        ENDataExtType DataExtType2753 = (ENDataExtType)DataExtRet.DataExtType.GetValue();
                                        //Get value of DataExtValue
                                        string DataExtValue2754 = (string)DataExtRet.DataExtValue.GetValue();
                                }
                        }
                }




        }
}