Search code examples
vb.netquickbooksqbfc

is there a way to query IEmployeePayrollInfo with QuickBooks SDK?


I am starting to work with the QuickBooks SDK, and so far I am able to query Employees no problem, like so:

_sessionManager.OpenConnection("", "<software>")
_sessionManager.BeginSession("", ENOpenMode.omDontCare)

Dim requestSet As IMsgSetRequest = GetLatestMsgSetRequest(_sessionManager)
' Initialize the message set request object
requestSet.Attributes.OnError = ENRqOnError.roeStop
Dim empQuery As IEmployeeQuery = requestSet.AppendEmployeeQueryRq()
' Do the request and get the response message set object
Dim responseSet As IMsgSetResponse = _sessionManager.DoRequests(requestSet)
Dim response As IResponse = responseSet.ResponseList.GetAt(0)

Dim empRetList As IEmployeeRetList = response.Detail
....
_sessionManager.EndSession()
_sessionManager.CloseConnection()

Which will give me a list of employees which I can iterate through. This works well for the basic employee data, such as name, date of birth, etc. but there is a EmployeePayrollInfo property that does not seem to be returned with the IEmployeeQuery.

I see that there is an interface IEmployeePayrollInfo but I have not as yet been able to figure out if there is a way to query it. I see that there are report related payroll info queries, but I am trying to query the EmployeePayrollInfo directly, to retrieve the vacation information. Is this something that can be done with QBFC?

EDIT

I was able to get this working, see accepted answer below.


Solution

  • For anyone searching for the same functionality, the only information I was able to find seems to indicate that Intuit has specifically excluded this functionality from the QuickBooks SDK for security reasons. What we ended up doing to solve our problem is create a custom report in QuickBooks that included all of the information that we needed, exported it as a CSV file, and then import it accordingly in our software. Same end result, but a couple more steps than we were originally hoping for. Hopefully Intuit will change their mind about excluding this from the SDK.

    UPDATE

    I have finally been able to query the EmployeePayrollInfo, what was needed was adding "EmployeePayrollInfo" to the query itself like so:

    empQuery.IncludeRetElementList.Add("EmployeePayrollInfo")
    

    So now the code looks like this:

    Dim sessionManager As New QBSessionManager
    sessionManager.OpenConnection2("", "<software>", ENConnectionType.ctLocalQBD)
    sessionManager.BeginSession("", ENOpenMode.omDontCare)
    
    Dim requestSet As IMsgSetRequest = sessionManager.CreateMsgSetRequest("US", 12, 0)
    requestSet.Attributes.OnError = ENRqOnError.roeStop
    
    Dim empQuery As IEmployeeQuery = requestSet.AppendEmployeeQueryRq()
    empQuery.IncludeRetElementList.Add("EmployeePayrollInfo") ' this line did the trick!
    
    Dim responseSet As IMsgSetResponse = sessionManager.DoRequests(requestSet)
    Dim response As IResponse = responseSet.ResponseList.GetAt(0)
    
    Dim empRetList As IEmployeeRetList = response.Detail
    
    If empRetList.Count > 0 Then
        For i As Integer = 0 To empRetList.Count - 1
            Dim emp As IEmployeeRet = empRetList.GetAt(i)
    
            If emp IsNot Nothing Then
                ' do something with the queried data
            End If
        Next
    End If
    
    sessionManager.EndSession()
    sessionManager.CloseConnection()