Select to view content in your preferred language

how to query related table in offline geodatabase

2464
2
02-18-2016 08:24 PM
TobiasFimpel1
Frequent Contributor

When I query a related (non-spatial) table in an offline geodatabase the relatedResults object is not what I would expect. Can somebody help me understand what I'm doing wrong in the below code? Or perhaps post a code sample of how to query related records in an offline geodatabase? Thank you!

Here is what I'm doing:

//a runtime geodatabase with a points layer an a related table

    Geodatabase {

        id: gdb2

        path:gdbPath2

    }

// set up the query parameters. I know that related records exist for a point feature with ObjectID = 2, I verified by converting the runtime gdb to file geodatabase with ArcMap

   QueryRelatedRecordsParameters {

        id: relatedQueryParam

        outFields: ["OBJECTID"]

        relationshipId: 0

        objectIds: ['2']

    }

// then I execute queryRelated

localPointsTable.queryRelated(relatedQueryParam)

// then onQueryRelatedStatusChanged I access the relatedResults

GeodatabaseFeatureTable {

        id: localPointsTable

        geodatabase: gdb2.valid ? gdb2 : null

        featureServiceLayerId: 0

        onQueryRelatedStatusChanged: {

            console.log(queryRelatedStatus) // returns '1' (QueryRelatedStatusInProgress) , then '2' (QueryRelatedStatusCompleted)

    console.log(relatedResults) // this returns '[object Object]'

    console.log(relatedResults.json) // this returns 'undefined'

        }

    }


					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
Tags (2)
0 Kudos
2 Replies
HannahFerrier
Deactivated User

There is a Query Related Records sample in AppStudio for a feature service, but it should point you in the right direction

To use the samples in AppStudio, double-click on New App, select the Samples category and scroll down until you find the Query Related Records sample project.

Enter a project title and click OK.

Now open your new project in Qt Creator to look at the source code

Hope this helps,

Hannah

0 Kudos
TobiasFimpel1
Frequent Contributor

Thank you for your reply Hannah. I studied that sample. I was unable to get it to work with data stored in a .geodatabase file. Is this perhaps a bug?

I have since moved on and decided to completely skip using the relationship class functionality and instead instantiate my related table as an ordinary GeodatabaseFeatureTable, build the Query with javascript to retrieve the correct records for a selected feature, and then listen for onQueryFeaturesStatusChanged on the table. That works, and I'm not sure whether using the relationship class functionality would actually have any advantages (?).

Thanks,

Tobias

0 Kudos