gpt4 book ai didi

c# - QuickBooks SDK - 如何获取自定义字段和职位?

转载 作者:太空狗 更新时间:2023-10-30 01:05:12 25 4
gpt4 key购买 nike

我想知道如何使用 QuickBooks SDK。我有一份从 quickbooks 获得的员工列表,如何获取我在 QuickBooks 中为员工设置的自定义字段?

对于员工的内置字段,还有一个“职位名称”,SDK 中有一个 JobTitle,但它始终为空?

无论如何要获取自定义字段和职位名称?

谢谢

这是我用来在 QuickBooks 中获取员工对象的代码,但是我需要获取自定义字段和 JobTitle(但 JobTitle 始终为 null,即使它在 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
{ }

最佳答案

好吧,经过大量的尝试和错误,我已经解决了这个问题的一半,即获取自定义字段的部分!您必须设置查询以获取它们,然后您可以访问自定义字段,但如果您有多个自定义字段,我发现的最好方法是必须遍历它们以找到您想要的字段。这是下面的代码。

        employeeQuery.IncludeRetElementList.Add("DataExtRet");
employeeQuery.OwnerIDList.Add("0");

for (int x = 0; x < employee.DataExtRetList.Count; x++)
{
// get the dataExt object, now you have access to the custom field
IDataExtRet dataExt = employee.DataExtRetList.GetAt(x);
string customFieldName = dataExt.DataExtName.GetValue();
string value = dataExt.DataExtValue.GetValue();
}

关于c# - QuickBooks SDK - 如何获取自定义字段和职位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19897793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com