我想知道使用 QuickBooks SDK。我有一个从 QuickBooks 中获得的员工列表,如何获取我在 QuickBooks 中为员工设置的自定义字段?
还有员工的内置字段,有一个“职位”,SDK有一个职位,但它总是空的?
无论如何要获得自定义字段和职位?
谢谢
这是我用来在 QuickBooks 中获取员工对象的代码,但是我需要获取自定义字段和 JobTitle(但 JobTitle 始终为空,即使它在 QuickBooks 中设置)。
using QBFC12Lib;
QBSessionManager sessionManager = null;
try
{
// create the session manager
sessionManager = new QBSessionManager();
sessionManager.OpenConnection("", "Test Employee");
sessionManager.BeginSession(@"C:\PathTo\CompanyFile.qbw", ENOpenMode.omDontCare);
//Create the message set request object to hold our request
IMsgSetRequest request = sessionManager.CreateMsgSetRequest("US", 8, 0);
request.Attributes.OnError = ENRqOnError.roeContinue;
// create the employee query
IEmployeeQuery employeeQuery = request.AppendEmployeeQueryRq();
// send the request and get the response from QuickBooks
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(request);
IResponse response = responseMsgSet.ResponseList.GetAt(0);
IEmployeeRetList employeeRetList = (IEmployeeRetList)response.Detail;
if (employeeRetList != null)
{
for (int i = 0; i < employeeRetList.Count; i++)
{
// create employee item
IEmployeeRet employee = employeeRetList.GetAt(i);
// only get active employees
if (employee.IsActive.GetValue())
{
string firstName = employee.FirstName.GetValue();
string jobTitle = employee.JobTitle.GetValue();
}
}
}
}
catch
{ }