Start a new topic

Opening a Query in API

Hi,

I'm trying to open a query through API to check if the import constituent is in the query and if they are I need to do some things to their record.  I found some code on the forum for creating an array to hold the query info and then using it later on in the import.  Here is my code for creating the array.  I keep getting the error message that my query doesn't exist or I don't have access to it (see error message below).

Is there something off in my code?

 

Thanks for any help anyone has.

Public wdParents(,) As String 'array that holds data from "Parents Alum Donors Volunteers"

Public queryLength As Long 'the length of the "Test Parents" query

Public Overrides Sub BeforeImport(ByVal Cancel As ImportOM.API.iCancel)

MyBase.BeforeImport(Cancel)

Dim oQuery As New Blackbaud.PIA.RE7.BBREAPI.CQueryObject

Dim queryLength As Long

oQuery.Init(Import.SessionContext)

oQuery.LoadByField(1,"Test Parents")

oQuery.QuerySet.OpenQuerySet

queryLength = oQuery.QuerySet.NumberOfRecords

Dim queryArray(queryLength,1) As String

wdParents = queryArray

Do While Not oQuery.QuerySet.EOF

wdParents(oQuery.QuerySet.RowNum, 0) = oQuery.QuerySet.fieldValue(1) 'this should hold the ID#

wdParents(oQuery.QuerySet.RowNum, 1) = oQuery.QuerySet.fieldValue(2) 'this should hold the name

oQuery.QuerySet.MoveNext

loop

oQuery.QuerySet.CloseDown

End Sub

image


Lisa Folger

Southern New Hampshire University

1 Comment


hi 

try changing  the 1 to 2 in loadbyField parameter

      oQuery.LoadByField(1,"Test Parents")


     oQuery.LoadByField(2,"Test Parents")


(of course make sure you have a query called 'Test Parents' on RE!)

 

This works for me, RE 7.95 IOM 2.7.1.6 - all it does is count records in my Query

 

'Import has not been started yet

Dim oq As New Blackbaud.PIA.RE7.BBREAPI.CQueryObject

Dim qLen As Long

oq.Init(import.SessionContext)

oq.LoadByField(2, "test_myRecords")

oq.QuerySet.OpenQuerySet

qlen=oq.QuerySet.NumberOfRecords

msgbox(qlen)

oq.CloseDown

Login to post a comment