Querying a table does not return all fields

497
5
Jump to solution
10-16-2018 06:41 AM
KyleSchultz1
New Contributor II
               ServiceFeatureTable {
                           id: workLogTable
                           url: ""
                           credential: Credential {
                               username: ''
                               password: ''
                           }
                           onQueryFeaturesResultsChanged: {
                       
                               if (queryFeaturesStatus === Enums.TaskStatusCompleted) {
                                   if (!queryFeaturesResult.iterator.hasNext) {
                                       return;
                                   }
                                 
                                   workLog.clearSelection();
                                   var features = []
                                   while (queryFeaturesResult.iterator.hasNext) {
                                       features.push(queryFeaturesResult.iterator.next());
                                   }
                                   workLog.selectFeatures(features);
                                   var identifiedObjects =[]
                                   var elem = features[0];
                                   identifiedObjects.push(elem);
                                   displayAttributesModel.append(elem);
                                   for (z = 0; z < displayAttributesModel.rowCount(); z++) {
                                       console.log(JSON.stringify(displayAttributesModel.get(z).attributes.attributeNames))
                                   }
                            }
                           }
}

I have this code that is being invoked 
        params.whereClause = "GlobalID = '" + activeID+"'" ;
        workLogTable.queryFeatures(params);

I have all these fields
  • OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID , editable: false , nullable: false )
  • CREW_RESPONDING ( type: esriFieldTypeString , alias: CREW , editable: true , nullable: true , length: 1073741822 )
  • WORK_SUMMARY ( type: esriFieldTypeString , alias: WORK_SUMMARY , editable: true , nullable: true , length: 1073741822 )
  • WORK_DETAILS ( type: esriFieldTypeString , alias: WORK_DETAILS , editable: true , nullable: true , length: 1073741822 )
  • HOURS ( type: esriFieldTypeDouble , alias: HOURS , editable: true , nullable: true )
  • MATERIALS_USED ( type: esriFieldTypeString , alias: MATERIALS_USED , editable: true , nullable: true , length: 1073741822 )
  • EQUIPMENT_USED ( type: esriFieldTypeString , alias: EQUIPMENT_USED , editable: true , nullable: true , length: 1073741822 )
  • BOIL_ADVISORY ( type: esriFieldTypeString , alias: BOIL_ADVISORY , editable: true , nullable: true , length: 75 )
  • ACCIDENT ( type: esriFieldTypeString , alias: ACCIDENT , editable: true , nullable: true , length: 75 )
  • LAW ( type: esriFieldTypeString , alias: LAW , editable: true , nullable: true , length: 75 )
  • WORK_TITLE ( type: esriFieldTypeString , alias: WORK_TITLE , editable: true , nullable: true , length: 75 )
  • CREW_ADDITIONAL ( type: esriFieldTypeString , alias: ADDITIONAL , editable: true , nullable: true , length: 1073741822 )
  • CREATED_BY ( type: esriFieldTypeString , alias: DATA_ENTRY , editable: true , nullable: true , length: 75 )
  • GlobalID ( type: esriFieldTypeGlobalID , alias: GlobalID , editable: false , nullable: false , length: 38 )
  • created_user ( type: esriFieldTypeString , alias: created_user , editable: false , nullable: true , length: 255 )
  • created_date ( type: esriFieldTypeDate , alias: created_date , editable: false , nullable: true , length: 36 )
  • last_edited_user ( type: esriFieldTypeString , alias: last_edited_user , editable: false , nullable: true , length: 255 )
  • last_edited_date ( type: esriFieldTypeDate , alias: last_edited_date , editable: false , nullable: true , length: 36 )
  • STATUS ( type: esriFieldTypeString , alias: STATUS , editable: true , nullable: true , length: 75 )
  • DEPARTMENT ( type: esriFieldTypeString , alias: DEPARTMENT , editable: true , nullable: true , length: 75 )
  • UPDATED_BY ( type: esriFieldTypeString , alias: UPDATED_BY , editable: true , nullable: true , length: 75 )
  • CLOSED_BY ( type: esriFieldTypeString , alias: CLOSED_BY , editable: true , nullable: true , length: 75 )

So the line 

console.log(JSON.stringify(displayAttributesModel.get(z).attributes.attributeNames))

is only outputting 

qml: {"0":"created_date","1":"created_user","2":"CREW_RESPONDING","3":"GlobalID","4":"last_edited_date","5":"last_edited_user","6":"OBJECTID"}

meaning the majority of my fields aren't being returned. So attribute values I need to display are not being displayed in my app.

Is this a known issue? Is there a way to solve it and return all fields?

0 Kudos
1 Solution

Accepted Solutions
KeithLarson1
MVP

Sure. All you need to do is replace this:

         params.whereClause = "GlobalID = '" + activeID+"'" ;
         workLogTable.queryFeatures(params);


with this:

         params.whereClause = "GlobalID = '" + activeID+"'" ;
         workLogTable.queryFeaturesWithFieldOptions(params, Enums.QueryFeatureFieldsLoadAll);

View solution in original post

5 Replies
KeithLarson1
MVP

If I'm understanding this correctly, this is the same problem I was having before. I was able to specify the fields to return with the queryFeaturesWithFieldOptions function rather than queryFeatures. I passed it Enums.QueryFeatureFieldsLoadAll to return all fields. It is documented here: ServiceFeatureTable QML Type | ArcGIS for Developers . Hope that helps.

0 Kudos
KyleSchultz1
New Contributor II

Could you post an example of how you used it?

0 Kudos
KeithLarson1
MVP

Sure. All you need to do is replace this:

         params.whereClause = "GlobalID = '" + activeID+"'" ;
         workLogTable.queryFeatures(params);


with this:

         params.whereClause = "GlobalID = '" + activeID+"'" ;
         workLogTable.queryFeaturesWithFieldOptions(params, Enums.QueryFeatureFieldsLoadAll);

KyleSchultz1
New Contributor II

Thank you, such a simple soultion

0 Kudos
ErwinSoekianto
Esri Regular Contributor

I think this is similar to this thread, How to use QueryParameters and specify outFields?  

It is because there is no outfields parameter being set, someone has reported success using "queryFeaturesWithFieldOptions" method which will return all fields. 

cc: ArcGIS Runtime SDK for Qt

0 Kudos