Update Features

1366
18
05-07-2019 01:26 PM
jaykapalczynski
Frequent Contributor

I am referencing the Update feature template in AppStudio.....

I am trying to add another Combobox AND Text field that will be populated with the appropriate values once the feature is selected.  If I add the variable below "varhabitable" The popup never occurs to allow me to click into the update popup.

If I comment this line

varhabitable = selectedFeature.attributes.attributeValue("habitable");

I can run the app but the combobox is not populated with the value of that record.

How do I build the update box with multiple Fields for update including text fields?

// signal handler for selecting features
onSelectFeaturesStatusChanged: {
   if (selectFeaturesStatus === Enums.TaskStatusCompleted) {
      if (!selectFeaturesResult.iterator.hasNext)
          return;

         selectedFeature = selectFeaturesResult.iterator.next();
         vardamageType = selectedFeature.attributes.attributeValue("typdamage");
         varhabitable = selectedFeature.attributes.attributeValue("habitable");


         // show the callout
        callout.x = mousePointX;
        callout.y = mousePointY;
        callout.visible = true;

     // set the combo box's default value
       damageComboBox.currentIndex = featAttributes.indexOf(vardamageType);
       damageComboBox2.currentIndex = featAttributes.indexOf(varhabitable);

      }
  }

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
18 Replies
jaykapalczynski
Frequent Contributor

I ran the app in QT Creator with this:  

To run your app in Qt Creator, click Run on the Tools > External > AppStudio menu. (You can also press Alt+Shift+R on your keyboard.)

I see this error:  

ArcGIS.AppFramework.Player: Object: QObject(0x0) Text: "file:///C:/Users/tjv36463/ArcGIS/AppStudio/Apps/25ab7e6bad9b43508700122d31c63f43/Samples/UpdateFeatures.qml:124: Error: Cannot assign [undefined] to QString"

file:///C:/Users/tjv36463/ArcGIS/AppStudio/Apps/25ab7e6bad9b43508700122d31c63f43/Samples/UpdateFeatures.qml:124: Error: Cannot assign [undefined] to QString

The funny thing is I am positive there are values in the data for the fields ... very puzzled...will try and reach out to ESRI for solution

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Jay, 

Yes, at this point, it is best to work with Esri Technical Support‌ on this issue, so that we can troubleshoot to see what is missing. 

Erwin

0 Kudos
jaykapalczynski
Frequent Contributor

This is my exact code trying to hit a service of mine....everything is UNDEFINED.

I reached out to ESRI but nothing...

thoughts?

import QtQuick 2.7
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtGraphicalEffects 1.0

import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.2

import "../controls" as Controls

Item {
    id:setInitialMapArea

    property real scaleFactor: AppFramework.displayScaleFactor
    property int baseFontSize : app.info.propertyValue("baseFontSize", 15 * scaleFactor) + (isSmallScreen ? 0 : 3)
    property bool isSmallScreen: (width || height) < units(400)
    property double mousePointX
    property double mousePointY

    property var selectedFeature: null

    property var varWMA: null

    property var vardamageType: null






//    property string inspectorname

    // Create MapView that contains a Map with the Imagery Basemap
    // Create MapView that contains a Map
    MapView {
        id: mapView
        anchors.fill: parent
        wrapAroundMode: Enums.WrapAroundModeDisabled

        Map {
            id:map
            // Set the initial basemap to Streets
            BasemapStreets { }

            // set viewpoint over The United States
            ViewpointCenter {
                Point {
                    x: -10800000
                    y: 4500000
                    spatialReference: SpatialReference {
                        wkid: 102100
                    }
                }
                targetScale: 3e7
            }

            FeatureLayer {
                id: featureLayer

                selectionColor: "cyan"
                selectionWidth: 3

                // declare as child of feature layer, as featureTable is the default property
                ServiceFeatureTable {
                    id: featureTable
                    //url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0"
                    url: "https://vafwisdev.dgif.virginia.gov/arcgis/rest/services/DGIF_Test/TestRegions/FeatureServer/0"


                    // make sure edits are successfully applied to the service
                    onApplyEditsStatusChanged: {
                        if (applyEditsStatus === Enums.TaskStatusCompleted) {
                            console.log("successfully updated feature");
                        }
                    }

                    // signal handler for the asynchronous updateFeature method
                    onUpdateFeatureStatusChanged: {
                        if (updateFeatureStatus === Enums.TaskStatusCompleted) {
                            // apply the edits to the service
                            featureTable.applyEdits();
                        }
                    }
                }



              //  property var car: ({example: ''})



                // signal handler for selecting features
                onSelectFeaturesStatusChanged: {

                    if (selectFeaturesStatus === Enums.TaskStatusCompleted) {
                        if (!selectFeaturesResult.iterator.hasNext)
                            return;

                       selectedFeature = selectFeaturesResult.iterator.next();


                       //vardamageType = selectedFeature.attributes.attributeValue("City_Numbe");


                       varWMA = selectedFeature.attributes.attributeValue("Duplicate");
                       var valuevarWMA = selectedFeature.attributes.attributeValue("County_Nam");
                       //var varFGSymbol = selectedFeature.attributes.attributeValue("FG_Symbol");


console.log("=================================================");
console.log(varWMA);
console.log(valuevarWMA);
console.log(typeof valuevarWMA);
console.log("=================================================");

                        // show the callout
                        callout.x = mousePointX;
                        callout.y = mousePointY;
                        callout.visible = true;

                        // set the combo box's default value
                        //damageComboBox.currentIndex = featAttributes.indexOf(vardamageType);

                        notesfield.text = "Value is: " + varWMA;
                        notesfield2.text = "Value is: " + valuevarWMA;
                    }

                }
            }
        }

        QueryParameters {
            id: params
            maxFeatures: 1
        }


        // hide the callout after navigation
        onViewpointChanged: {
            callout.visible = false;
            updateWindow.visible = false;
        }

        onMouseClicked: {
            // reset the map callout and update window
            featureLayer.clearSelection();
            callout.visible = false;
            updateWindow.visible = false;

            mousePointX = mouse.x;
            mousePointY = mouse.y - callout.height;
            mapView.identifyLayerWithMaxResults(featureLayer, mouse.x, mouse.y, 10, false, 1);
        }

        onIdentifyLayerStatusChanged: {
            if (identifyLayerStatus === Enums.TaskStatusCompleted) {
                if (identifyLayerResult.geoElements.length > 0) {
                    // get the objectid of the identifed object
                    params.objectIds = [identifyLayerResult.geoElements[0].attributes.attributeValue("objectid")];
                    // query for the feature using the objectid
                    featureLayer.selectFeaturesWithQuery(params, Enums.SelectionModeNew);
                }
            }
        }
        //Busy Indicator
        BusyIndicator {
            anchors.centerIn: parent
            height: 48 * scaleFactor
            width: height
            running: true
            Material.accent:"#8f499c"
            visible: (mapView.drawStatus === Enums.DrawStatusInProgress)
        }
    }

    // map callout window
    Rectangle {
        id: callout
        width: row.width + (10 * scaleFactor) // add 10 for padding
        height: 40 * scaleFactor
        radius: 5

        border {
            color: "lightgrey"
            width: .5
        }
        visible: false

        MouseArea {
            anchors.fill: parent
            onClicked: mouse.accepted = true
        }

        Row {
            id: row
            anchors {
                verticalCenter: parent.verticalCenter
                left: parent.left
                margins: 5 * scaleFactor
            }
            spacing: 10

// TEXT ON THE POPUP TO MODIFY THE RECORD
            Text {
                Material.accent: "#8f499c"
                text: "damage type " + varWMA
                font.pixelSize: 18 * scaleFactor
            }

            Rectangle {
                radius: 100
                width: 22 * scaleFactor
                height: width
                color: "transparent"
                border.color: "blue"
                antialiasing: true

                Text {
                    anchors.centerIn: parent
                    text: "i"
                    font.pixelSize: 18 * scaleFactor
                    color: "blue"

                }

                // create a mouse area over the (i) text to open the update window
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        updateWindow.visible = true;
                    }
                }
            }
        }
    }

    // Update Window
    Rectangle {
        id: updateWindow
        anchors.centerIn: parent
        width: 300 * scaleFactor
        height: 300 * scaleFactor
        radius: 10
        visible: false
        Material.accent: "#8f499c"

        GaussianBlur {
            anchors.fill: updateWindow
            source: mapView
            radius: 40
            samples: 20
        }

        MouseArea {
            anchors.fill: parent
            onClicked: mouse.accepted = true
            onWheel: wheel.accepted = true
        }

        Column {
            anchors {
                fill: parent
                margins: 10 * scaleFactor
            }
            spacing: 10
            Row {
                anchors.horizontalCenter: parent.horizontalCenter
                Text {
                    text: "Update Attribute"
                    font.pixelSize: 16 * scaleFactor
                }
            }
/*
            ComboBox {
                id: damageComboBox
                width: updateWindow.width - (20 * scaleFactor)
                model: featAttributes
            }
*/

            Text {
                id: notesfield
              //text: valuevarWMA
               color: "blue"
               width: updateWindow.width - (20 * scaleFactor)
            }


            TextField {
              id: notesfield2
             // text: varWMA
              width: updateWindow.width - (20 * scaleFactor)
            }


            Row {
                anchors.horizontalCenter: parent.horizontalCenter
                spacing: 10

                Button {
                    width: (updateWindow.width / 2) - (20 * scaleFactor)
                    text: "Update"

                    function doUpdateAttribute(){
                        if (selectedFeature.loadStatus === Enums.LoadStatusLoaded) {
                            selectedFeature.onLoadStatusChanged.disconnect(doUpdateAttribute);

                           // selectedFeature.attributes.replaceAttribute("TYPE", damageComboBox.currentText);
                           // selectedFeature.attributes.replaceAttribute("WMA", damageComboBox2.text);
                           // selectedFeature.attributes.replaceAttribute("WMA", "Amelia");

                        }
                    }

                    // once the update button is clicked, hide the windows, and fetch the currently selected features
                    onClicked: {
                        callout.visible = false;
                        updateWindow.visible = false;

                        selectedFeature.onLoadStatusChanged.connect(doUpdateAttribute);
                        selectedFeature.load();
                    }
                }

                Button {
                    width: (updateWindow.width / 2) - (20 * scaleFactor)
                    text: "Cancel"
                    // once the cancel button is clicked, hide the window
                    onClicked: updateWindow.visible = false;
                }
            }
        }
    }



    } // End ITEM
0 Kudos
ErwinSoekianto
Esri Regular Contributor

I reached out to ESRI but nothing...

I checked with Esri Technical Support‌, we don't see any support case related to this issue. We saw other support cases that have been closed. 

If this is a mistake please let us know (the support case number if you have it), we would be glad to help. 

0 Kudos
jaykapalczynski
Frequent Contributor

I swear I reached out to them....if not my mistake...I will try once again...

0 Kudos
jaykapalczynski
Frequent Contributor

I posted this in the Support section...never heard back

https://community.esri.com/thread/233828-update-feature-to-textfield-not-working

0 Kudos
jaykapalczynski
Frequent Contributor

Is there another location I should forward this to Erwin?

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Jay, sorry if I was not very clear. I meant to say to contact Esri Technical Support, https://support.esri.com/en/contact-tech-support, we have analysts/specialists who would be able to troubleshoot this with you, 

0 Kudos
jaykapalczynski
Frequent Contributor

OK will try that....was going on your prior post to contact https://community.esri.com/groups/technical-support ...

Got it now...I will place a Support Request and go that route to see if I can get some help....

MUCH Appreciated.

0 Kudos