how can i get AGSRelatedFeatureQueryResult with all field values?

179
7
12-30-2018 08:09 PM
PrasadJ
New Contributor II

Please help me to resolve the issue.

i need to display all the field values of the relation table information of a feature on related feature class,

But we are not getting full attribute information

below code snippet 

self.featureTableParking.queryRelatedFeatures(for: self.selectedParking ) { [weak self] (results:[AGSRelatedFeatureQueryResult]?, error:Error?) in

            

            if let error = error {

                

                //display error

                self?.presentAlert(error: error)

            }

            else {

....

}

below is the snippet for extracting the field of "totalspots" but i am getting value of displayFieldName

    let result = self.results[0]

        let feature = result.featureEnumerator().allObjects[indexPath.row]

        

        

        let displayFieldName = result.relatedTable!.layerInfo!.displayFieldName

        let fields=result.relatedTable!.fields

        print(fields)

       let value1 = feature.attributes.value(forKeyPath: "TOTALSPOT")

     print(value1.debugDescription)

how can i get all the attribute information of all field

Reply
0 Kudos
7 Replies
NimeshJarecha
Esri Regular Contributor

Hi Prasad,

What result you see for the following code? Does it print only one field or all fields?

        let fields=result.relatedTable!.fields

        print(fields)

Regards,

Nimesh

Reply
0 Kudos
PrasadJ
New Contributor II

Hi Nimesh,

It is printing all the fields info but corresponding values not getting.

Regards,

Prasad

Reply
0 Kudos
NimeshJarecha
Esri Regular Contributor

Hi Prasad,

Can you post result of following print statements. I would like to see how many fields are present and what attributes you are getting.

        let fields=result.relatedTable!.fields

        print(fields)

let feature = result.featureEnumerator().allObjects[indexPath.row]

print(feature.attributes)

Regards,

Nimesh

Reply
0 Kudos
PrasadJ
New Contributor II

Dear Nimesh,

Below is the result we are getting. i need all the attributes value but we

are getting only 3 fields value.

Please suggest

let fields=result.relatedTable!.fields

print(fields)

Result:

*[Name:OBJECTID; Type:8; Alias:OBJECTID; Editable:0, Name:FACILITYID;

Type:7; Alias:Space Identifier; Editable:0, Name:SPACENAME; Type:7;

Alias:Name; Editable:0, Name:LOCDESC; Type:7; Alias:Location; Editable:0,

Name:OPERDAYS; Type:7; Alias:Operational Days; Editable:0, Name:OPERHOURS;

Type:7; Alias:Operational Hours; Editable:0, Name:RESTRICTION; Type:7;

Alias:Parking Restrictions; Editable:0, Name:TOTALSPOT; Type:0; Alias:Total

Spots; Editable:0, Name:OWNEDBY; Type:0; Alias:Owned By; Editable:0,

Name:MAINTBY; Type:0; Alias:Managed By; Editable:0, Name:GLOBALID; Type:9;

Alias:GLOBALID; Editable:0, Name:LOCATION; Type:7; Alias:LOCATION;

Editable:0]*

let feature = result.featureEnumerator().allObjects[indexPath.row]

print(feature.attributes)

Result:

{

  • GLOBALID = "F72D453A-30DE-43D3-895D-7232B4E68A07";*

  • LOCATION = P2;*

  • OBJECTID = 11;*

  • SPACENAME = "Second Floor";*

}

...

Reply
0 Kudos
NimeshJarecha
Esri Regular Contributor

Hi Prasad,

Please use queryRelatedFeaturesForFeature:parameters:queryFeatureFields:completion: method to query related feature and specify `queryFeatureFields` as `AGSQueryFeatureFieldsLoadAll`.

Hope this helps!

Regards,

Nimesh

PrasadJ
New Contributor II

Hi Nimesh,

Thank you for your help

it is working fine

Reply
0 Kudos
NimeshJarecha
Esri Regular Contributor

I'm glad it worked for you. Can you please mark the answer helpful?

Regards,

Nimesh

Reply
0 Kudos