Save User Info in Quick Report When App is Closed

1123
6
Jump to solution
12-01-2017 10:36 AM
KE
by
Occasional Contributor

I am using the Quick Report template with AppStudio Standard. Some of the information my app collects is contact information (name, phone, email) that is sent in with each report. I would like to make it more convenient for the user and save their contact information in the app, so they don't have to enter it every time. Right now this information is added in the 'Add Details' page.

Ideally, I was thinking there would be a page for them to enter this info when they first download the app that would not pop up again each time they open the app. Then their info would then be saved in the Settings page, and be available for the user to edit anytime. Then I could send that information with the report each time they submit.

For simplicity's sake, since I'm pretty new to this, Is there a way to save the information they write in the Add Details page, so it is still there next time they open the app?

0 Kudos
1 Solution

Accepted Solutions
ErwinSoekianto
Esri Regular Contributor

Hello K E, 

I just want to follow up on this question, based on your feedback, we have added this functionality in Quick Report template 4.3, please see this blog post for more details and how to download AppStudio 4.3 Beta,

https://community.esri.com/groups/appstudio/blog/2020/07/13/introducing-arcgis-appstudio-43-beta 

Thank you,

Erwin

View solution in original post

6 Replies
ErwinSoekianto
Esri Regular Contributor

K E

Thank you for your post!

This is currently not supported with the out-of-the-box Quick Report template.

With that being said, such customization is definitely possible, since you would have full access to the source code of the Quick Report template in AppStudio Desktop. 

If I were to do this, I would take advantage of the QuickReport Properties in the Setting page, customize it by editing the appschema.json and appinfo.json, to add all the information that you need. 

And then add this information to the AddDetailsPage.qml, depending on the fields or attributes that the information needs to go. 

You mentioned that you are pretty new with this, so spend some time looking around the source code of the Quick Report template, so that you are comfortable making this customization. 

I hope this is helpful, and let us know if you have any other questions along the way.

Thanks,

Erwin. 

KE
by
Occasional Contributor

Thank you for your direction Erwin Soekianto! I feel like I'm making good progress on this but I have another question. Here's what I have so far:

I edited the properties in appinfo.json and QuickReportApp.qml instead of appschema.json. I'm not sure if the appinfo.json portion is needed or what it is used for, or if I still need to put something in the appschema.json, but I figured out that if you add a property to app.settings it gets saved when the app is closed.

appinfo.json

"userEmail": "",
 "userFullName": "",
 "userPhone": "",‍‍‍

QuickReportApp.qml

property string userFullName: app.settings.value("userFullName", "")
property string userPhone: app.settings.value("userPhone", "")
property string userEmail: app.settings.value("userEmail", "")‍‍‍


‍‍‍‍

In the SettingsPage.qml, I created 3 new rectangles and added 3 new controls (boxes for the user to save their info):

                            Text{
                                Layout.fillWidth: true
                                anchors.verticalCenter: parent.verticalCenter
                                text: qsTr("Name")
                                fontSizeMode: Text.Fit
                                font.pixelSize: app.textFontSize
                                font.family: app.customTitleFont.name
                                color: app.subtitleColor
                            }
                            NewControls.TextField {
                                id: textFullName
                                text: app.userFullName
                                onTextChanged: {
                                    app.settings.setValue("userFullName", textFullName.text)
                                }
                            }

                            Text{
                                Layout.fillWidth: true
                                anchors.verticalCenter: parent.verticalCenter
                                text: qsTr("Phone Number")
                                fontSizeMode: Text.Fit
                                font.pixelSize: app.textFontSize
                                font.family: app.customTitleFont.name
                                color: app.subtitleColor
                            }
                            NewControls.TextField {
                                id: textPhone
                                text: app.userPhone
                                validator: RegExpValidator { regExp: /^[0-9\+\-\#\*\ ]{6,}$/ }
                                inputMask: "000-000-0000"
                                inputMethodHints: Qt.ImhDialableCharactersOnly
                                onTextChanged: {
                                    app.settings.setValue("userPhone", textPhone.text)
                                }
                            }

                            Text{
                                Layout.fillWidth: true
                                anchors.verticalCenter: parent.verticalCenter
                                text: qsTr("Email")
                                fontSizeMode: Text.Fit
                                font.pixelSize: app.textFontSize
                                font.family: app.customTitleFont.name
                                color: app.subtitleColor
                            }
                            NewControls.TextField {
                                id: textEmail
                                text: app.userEmail
                                validator: RegExpValidator { regExp: /^[A-Z][A-Z0-9._%+-]*@[A-Z0-9.-]+\.[A-Z]{2,4}$/i }
                                inputMethodHints: Qt.ImhEmailCharactersOnly
                                onTextChanged: {
                                    app.settings.setValue("userEmail", textEmail.text)
                                }
                            }

Then to force the Add Details page to populate with the saved settings, I edited the 'property var defaultValue' in AttributesPage.qml

property var defaultValue : fieldName == "email" ? app.userEmail : fieldName == "Phone" ? app.userPhone : fieldName == "Name" ? app.userFullName : hasPrototype ? featureTypes[pickListIndex].templates[0].prototype[modelData["name"]] : fieldType == Enums.FieldTypeText ? "" : null



Then the last piece of the puzzle is how to I force the user to fill out the settings when they first download the app?

0 Kudos
KE
by
Occasional Contributor

The Add Details page is not updating as I expected... It seems like the Component Loader on the AttributesPage.qml, where I changed the defaultValue, only runs when the app opens? Because if I change the settings, and then go to the Add Details page, it doesn't update unless I close the app and open it again.

0 Kudos
ErwinSoekianto
Esri Regular Contributor

K E

This is a great progress you have made so far. 

For this issue, I would take advantage of the Component.onCompleted on the Add Details page to get the data from appinfo and then update the defaultValue. 

Or, you can add a button in the Add Details page that would get the data and populate the text field, that way the end user can choose to either enter the information manually or auto-populate it from appinfo. 

Let me know if this makes sense. 

Erwin.

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Hello, 

Did you end up logging this enhancement with Esri Technical Support ? Do you have the bug or enhancement number from regarding this? If not I can help adding log it by providing your customer number.

We are working on adding this feature added on the Quick Report template, targeting our User Conference release timeline. 

Thank you,

Erwin.

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Hello K E, 

I just want to follow up on this question, based on your feedback, we have added this functionality in Quick Report template 4.3, please see this blog post for more details and how to download AppStudio 4.3 Beta,

https://community.esri.com/groups/appstudio/blog/2020/07/13/introducing-arcgis-appstudio-43-beta 

Thank you,

Erwin