2016-06-17 68 views
1

我在查看Onscreen Reference以查看是否存在查詢作業的XML請求。我發現只有客戶查詢請求CustomerQueryRq,並且也不返回它具有的子作業。查詢工作信息

假設這是客戶&工作中心的樣子:

- Customer 1 
    -- Job 1 
    -- Job 2 
    -- Job 3 

我能夠使用CustomerQueryRq並獲得詳細信息Customer 1,但找不到檢索Job 1什麼。

所以我的問題是我如何查詢一份工作,並得到它的父母客戶?我非常感謝任何幫助。

編輯:張貼我QBXML要求:

<?xml version="1.0" encoding="utf-8"?> 
<?qbxml version="13.0"?> 
<QBXML> 
    <QBXMLMsgsRq onError="continueOnError"> 
     <CustomerQueryRq requestID="1"> 
     <FullName>Customer name</FullName> 
     </CustomerQueryRq> 
    </QBXMLMsgsRq> 
</QBXML> 

Customer name有孩子的工作,我想查詢這些。

+0

發佈您的QBXML請求。 –

+0

感謝您的評論。發佈了QBXML請求。 –

回答

1

ICustomerQuery返回作業列表以及客戶列表。沒有單獨的作業查詢對象。每個工作都有一個客戶作爲父母。因此,您也可以檢索相關客戶的工作。 下面是一個例子:我有一個工作J1與我的公司文件中的客戶C1相關聯。在下面的C#代碼示例中,我創建了一個客戶查詢對象(使用QB SDK 13.0)並遍歷結果。我在顧客列表(C1和J1)中得到兩個結果:

using QBXMLRP2Lib; 
using Interop.QBFC13; 

public class SDKApp 
{ 

private QBSessionManager sessionMgr; 

public SDKApp() 
{ 
    // in the class constructor - sessionMgr is a member variable 
    sessionMgr = new QBSessionManager(); 
} 

public void GetData() 
{ 
// open connection and begin session before data fetch - intentionally skipped this code 

// during data fetch 
IMsgSetRequest msgset = sessionMgr.CreateMsgSetRequest("US", 13, 0); 
ICustomerQuery customerQuery = msgset.AppendCustomerQueryRq(); 
IMsgSetResponse msgRes = sessionMgr.DoRequests(msgset); 
IResponseList responseList = msgRes.ResponseList; 
if (responseList.Count > 0) 
{ 
    IResponse response = responseList.GetAt(0); 
    ICustomerRetList customerList = response.Detail as ICustomerRetList; 
    for (int i = 0; i <= customerList.Count - 1; i++) 
    { 
     ICustomerRet qbCustomer = customerList.GetAt(i); 
     string displayName = qbCustomer.Name.GetValue(); 
     string entityType = "Customer"; 
     if (qbCustomer.ParentRef != null) 
     { 
      entityType = "Job of " + qbCustomer.ParentRef.FullName.GetValue(); 
     } 
     Console.WriteLine(displayName + " " + entityType); 
    } 
} 

// end session and close connection after data fetch - intentionally skipped this code 
} 

} 
+0

謝謝納文!工作很好。 –