From 07e5b88830adb2b5c2f15a2d251b2af841bf8f33 Mon Sep 17 00:00:00 2001 From: Zachary Sutherby Date: Tue, 17 Aug 2021 10:55:45 -0700 Subject: [PATCH 1/3] Update update_attachment_keywords_in_arcgis_enterprise.ipynb --- .../update_attachment_keywords_in_arcgis_enterprise.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Update Attachment Keywords/update_attachment_keywords_in_arcgis_enterprise.ipynb b/Update Attachment Keywords/update_attachment_keywords_in_arcgis_enterprise.ipynb index 708c38b..0166fa3 100644 --- a/Update Attachment Keywords/update_attachment_keywords_in_arcgis_enterprise.ipynb +++ b/Update Attachment Keywords/update_attachment_keywords_in_arcgis_enterprise.ipynb @@ -44,7 +44,6 @@ "import re\r\n", "import datetime\r\n", "import requests\r\n", - "import arcpy\r\n", "import tempfile\r\n", "from IPython.display import display\r\n", "from arcgis.gis import GIS" @@ -136,7 +135,7 @@ "source": [ "def update_attachment(url, token, oid, attachment, attachID, keyword):\r\n", " att_url = '{}/{}/updateAttachment'.format(url, oid)\r\n", - " start, extension = arcpy.os.path.splitext(attachment)\r\n", + " start, extension = os.path.splitext(attachment)\r\n", "\r\n", " jpg_list = ['.jpg', '.jpeg']\r\n", " png_list = ['.png']\r\n", From 78cacc473f9fffc191b6a70d3d7b749a6f6b9a20 Mon Sep 17 00:00:00 2001 From: Zachary Sutherby Date: Tue, 17 Aug 2021 15:42:59 -0700 Subject: [PATCH 2/3] 1.9 updates for the work with reports notebook 1.9 updates for the work with reports notebook --- Work with Reports/README.md | 27 +- ...orts_using_the_arcgis_api_for_python.ipynb | 465 ++++++++++++++---- 2 files changed, 382 insertions(+), 110 deletions(-) diff --git a/Work with Reports/README.md b/Work with Reports/README.md index c145c38..a50dcff 100644 --- a/Work with Reports/README.md +++ b/Work with Reports/README.md @@ -1,26 +1,37 @@ -# Create reports using the ArcGIS API for Python (Guide) +# Working with Reports (Guide) ArcGIS Survey123 reports are an effective way to quickly visualize, interpret, and share survey responses. Reports use a template you can personalize, that's applied to your survey results and shared as either a Microsoft Word or PDF document. -It's common to deploy a [webhook](https://doc.arcgis.com/en/survey123/browser/create-surveys/webhooks.htm) as an automated process to create and share reports with survey results. Although, using a third party webhook provider may not be a feasible workflow due to organizational or security policies. This is where the ArcGIS Survey123 module in the ArcGIS API for Python can be used to acheive a similar goal. +There are several ways to create reports from your survey data. The most common method is through the Report panel on the Data tab for your survey on the Survey123 website. Here, you can manage report templates and generate reports in PDF and DOCX format. -This sample notebook demonstrates the following functionality: +You can also use a webhook to trigger a process to create and share reports that contain survey results. A webhook is useful if want the report to be triggered by an action. For example, each time a survey is submitted, a webhook can trigger the Create report module in Integromat to generate a report. For more information, see [Webhooks](https://doc.arcgis.com/en/survey123/browser/create-surveys/webhooks.htm). + +Another approach is to run an automated reporting process at regular intervals. For example, you might want to produce a report for all surveys submitted in the past week, month, or quarter. This is where the ArcGIS Survey123 module in the ArcGIS API for Python can be useful: you can set up a script and run it periodically as a scheduled task. + +This sample notebook demonstrates ways you can use the ArcGIS Survey123 module to work with reports and covers the following functionality: -- Generate a default report template - Identify report templates associated with a survey +- Generate a default report template +- Check template syntax +- Associate a report template with a survey +- Estimate credits +- Create sample report - Generate a single report +- Generate a report as a PDF - Generate multiple reports - Generate multiple reports and save to your organization -- List saved reports +- Generate a report with all possible parameters +- Update report template +- List saved reports -**Python notebook** that demonstrates how to automate the process of generating reports. +**Python Notebook** that demonstrates how to automate the process of generating reports. ### Requirements - Python 3.6+ -- Python IDE (ArcGIS Notebooks, Jupyter Notebook, JupyterLab) +- Python IDE (ArcGIS Online notebooks, Jupyter notebook, Notebook Server) - [ArcGIS API for Python](https://developers.arcgis.com/python/) - this module interacts with your ArcGIS organization ### Usage - Enter your ArcGIS organization credentials in the GIS connection. -- Enter the item ID of a form item. +- Enter the item ID of a Form item. - Update the template index with the correct index of your template when generating reports. diff --git a/Work with Reports/create_reports_using_the_arcgis_api_for_python.ipynb b/Work with Reports/create_reports_using_the_arcgis_api_for_python.ipynb index c98ff79..45a3b74 100644 --- a/Work with Reports/create_reports_using_the_arcgis_api_for_python.ipynb +++ b/Work with Reports/create_reports_using_the_arcgis_api_for_python.ipynb @@ -2,252 +2,513 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# Create reports using the ArcGIS API for Python" - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ - "
This notebook uses the ArcGIS API for Python. For more information, see the ArcGIS API for Python documentation and guides.
\r\n", - "\r\n", - "ArcGIS Survey123 reports are an effective way to quickly visualize, interpret, and share survey responses. Reports use a template you can personalize, that's applied to your survey results and shared as either a Microsoft Word or PDF document. \r\n", - "\r\n", - "It's common to deploy a webhook as an automated process to create and share reports with survey results. Although, you may want to automate this process over a specified time frame. For example you may the past week, month or quarter. This is where the ArcGIS Survey123 module in the ArcGIS API for Python can be used to acheive a similar goal. \r\n", - "\r\n", - "This sample notebook demonstrates ways you can use the ArcGIS Survey123 module to work with reports and covers the following functionality: \r\n", - "\r\n", - "* Generate a default report template\r\n", - "* Identify report templates associated with a survey\r\n", - "* Generate a single report\r\n", - "* Generate multiple reports\r\n", - "* Generate multiple reports and save to your organization\r\n", - "* List saved reports\r\n", - "\r\n", - "
The Survey123 report service is an ArcGIS Online Premium service. It takes 0.5 credits per survey report generated. For more information, see the Understand credits documentation.
\r\n", - "\r\n", + "
This notebook uses the ArcGIS API for Python. For more information, see the ArcGIS API for Python documentation and guides.
\n", + "\n", + "ArcGIS Survey123 reports are an effective way to quickly visualize, interpret, and share survey responses. Reports use a template you can personalize, that's applied to your survey results and shared as either a Microsoft Word or PDF document.\n", + "\n", + "There are several ways to create reports from your survey data. The most common method is through the **Report** panel on the Data tab for your survey on the Survey123 website. Here, you can manage report templates and generate reports in PDF and DOCX format.\n", + "\n", + "You can also use a webhook to trigger a process to create and share reports that contain survey results. A webhook is useful if want the report to be triggered by an action. For example, each time a survey is submitted, a webhook can trigger the **Create report** module in Integromat to generate a report. For more information, see Webhooks.\n", + "\n", + "Another approach is to run an automated reporting process at regular intervals. For example, you might want to produce a report for all surveys submitted in the past week, month, or quarter. This is where the ArcGIS Survey123 module in the ArcGIS API for Python can be useful: you can set up a script and run it periodically as a scheduled task.\n", + "\n", + "This sample notebook demonstrates ways you can use the ArcGIS Survey123 module to work with reports and covers the following functionality: \n", + "\n", + "* Identify report templates associated with a survey\n", + "* Generate a default report template\n", + "* Check template syntax\n", + "* Associate a report template with a survey\n", + "* Estimate credits\n", + "* Create sample report\n", + "* Generate a single report\n", + "* Generate a report as a PDF\n", + "* Generate multiple reports\n", + "* Generate multiple reports and save to your organization\n", + "* Generate a report with all possible parameters\n", + "* Update report template\n", + "* List saved reports\n", + "\n", + "
Printing of reports is an ArcGIS Online Premium Service that consumes credits. Reports are charged at a minimum cost of 0.5 credits. For more information, see Understand credits.
\n", + "\n", "The first step is to connect to your GIS." - ], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": 1, + "metadata": {}, + "outputs": [], "source": [ - "import arcgis\r\n", - "from arcgis.gis import GIS\r\n", + "import arcgis\n", + "from arcgis.gis import GIS\n", "gis = GIS(\"home\")" - ], - "outputs": [], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Next, a Survey Manager is defined, and a survey is accessed using the form's item ID. A survey in the Survey Manager is a single instance of a survey project that contains the item information and properties and provides access to the underlying survey dataset. For more information on Survey Manager, see the API Reference for the ArcGIS API for Python." - ], - "metadata": {} + ] }, { "cell_type": "code", "execution_count": 2, - "source": [ - "survey_manager = arcgis.apps.survey123.SurveyManager(gis)\r\n", - "survey_by_id = survey_manager.get(\"9f01838a15594cfdbb2eb69fafb60d75\")\r\n", - "print(survey_by_id)" - ], + "metadata": {}, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "\n" ] } ], - "metadata": {} + "source": [ + "survey_manager = arcgis.apps.survey123.SurveyManager(gis)\n", + "survey_by_id = survey_manager.get(\"e7709174ba48426c880e504e11319970\")\n", + "print(survey_by_id)" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", "### Identify report templates associated with a survey\n", "\n", - "Using the `report_templates` method any report template already associated with the survey will be returned in a list. For each template in the list the title is printed using the print statement below. " - ], - "metadata": {} + "The `report_templates` method returns a list of all report templates already associated with the survey. For each template in the list the title is printed using the print statement below. " + ] }, { "cell_type": "code", "execution_count": 3, - "source": [ - "templates = survey_by_id.report_templates\r\n", - "p = [print(t.title) for t in templates]" - ], + "metadata": {}, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ - "Water Quality Inspection_sampleTemplate\n" + "Water Quality Inspection\n" ] } ], - "metadata": {} + "source": [ + "templates = survey_by_id.report_templates\n", + "p = [print(t.title) for t in templates]" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", - "### Generating a default report template\n", + "### Generate a default report template\n", "\n", - "In the case where there are not any report templates associated with the survey, a default template can be generated using the `create_report_template` method. The `create_report_template` method creates a simple default template automatically downloads it to the `Temp` folder. The ArcGIS Survey123 module does not support uploading a new report template." - ], - "metadata": {} + "In the case where no report templates are associated with the survey, a default template can be generated using the `create_report_template` method. The `create_report_template` method creates a simple default template and downloads it to the `Temp` folder." + ] }, { "cell_type": "code", "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\\Temp\\template_30398\n" + ] + } + ], "source": [ - "new_template = survey_by_id.create_report_template()\r\n", + "new_template = survey_by_id.create_report_template()\n", "print(new_template)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Check template syntax\n", + "\n", + "The `check_template_syntax` method checks the report template and identifies any syntax issues that could lead to a failure when generating a report. The method requires a directory path to a template file. The output string indicates if the check was successful or not. If the check is unsuccessful, the output will also include an error message." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Result of template syntax check: {'success': True, 'individualSectionCount': 1, 'summarySectionCount': 0, 'details': []}\n" + ] + } ], + "source": [ + "check = survey_by_id.check_template_syntax(new_template)\n", + "print(\"Result of template syntax check:\", check)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Associate a report template with a survey\n", + "\n", + "The `upload_report_template` method associates a report template with a survey. First, the method checks the syntax in the template file. If the check is successful, the template is uploaded to your ArcGIS organization in the same folder as the survey and linked with the survey for use in reports. If the check is unsuccessful an error message is returned. The method takes one required parameter, `template_file` which is the directory path to the template file, and an optional parameter `template_name` which will be used as the item name when uploaded to your organization. If `template_name` is omitted, the name of the template file will be used as the name of the item." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, "outputs": [ { + "name": "stdout", "output_type": "stream", + "text": [ + "\n", + "Water Quality Inspection\n", + "PythonAPITemplate\n" + ] + } + ], + "source": [ + "upload_template = survey_by_id.upload_report_template(template_file=new_template, template_name=\"PythonAPITemplate\")\n", + "print(upload_template)\n", + "templates = survey_by_id.report_templates\n", + "p = [print(t.title) for t in templates]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Estimate credits\n", + "\n", + "For ArcGIS Online users, the number of credits that will be consumed by running a report with specific parameters can be estimated using the `estimate()` method. The method takes two parameters, the `report_template` item and a `where` clause." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { "name": "stdout", + "output_type": "stream", "text": [ - "/tmp/template.docx\n" + "The estimated amount of credits are: {'success': True, 'resultInfo': {'totalRecords': 189, 'cost': 94.5}}\n" ] } ], - "metadata": {} + "source": [ + "credits = survey_by_id.estimate(templates[1], where=\"1=1\")\n", + "print(\"The estimated amount of credits are: \", credits)" + ] }, { "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Create a sample report\n", + "\n", + "You can create a watermarked sample PDF report using the `create_sample_report` method. This method is similar to the `generate_report` method but it does not consume credits, making it useful for testing and refinement of your report template before you generate any formal reports.\n", + "\n", + "The `create_sample_report` method requires a template item as a parameter and can include the following optional parameters:\n", + "\n", + "- `where`—Specify which records to include in the report.\n", + "- `utc_offset`—Adjust dates and times to match a specific time zone.\n", + "- `report_title`—Specify the file name (without extension) of the output report file.\n", + "- `merge_files`—Use this parameter when multiple records are to be included in a single report file. The `merge_files` parameter accepts the following values:\n", + " - `none`—Print multiple records in split mode, where each record becomes a separated report file. This is the default value.\n", + " - `nextPage`—Print multiple records in merge mode, where the content of the next record starts on a new page.\n", + " - `continuous`—Print multiple records in merge mode, where the content of the next record starts on the same page as the previous record.\n", + "- `survey_item`—Provides additional information on survey structure. For example, Multiple Choice questions require this parameter in order to access information on list labels..\n", + "- `webmap_item`—Specify the basemap to use for geometry questions.\n", + "- `map_scale`—Specify the scale of the map used for geometry questions.\n", + "- `locale`—Apply a regional format to numbers, dates, and times.\n", + "\n", + "
Sample reports can print a maximum of 20 results at a time.
" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sample Report: \\Temp\\Sample_Report_sample.pdf\n" + ] + } + ], + "source": [ + "webmap = gis.content.search(query=\"title:Water Quality Inspection Web Map\", item_type=\"Web Map\")\n", + "wm_item=webmap[0]\n", + "sample = survey_by_id.create_sample_report(templates[1], where=\"objectid=1\", utc_offset=\"-07:00\", \n", + " report_title=\"Sample_Report\", merge_files=\"none\", survey_item=survey_by_id, \n", + " webmap_item=wm_item, map_scale=\"10000\", locale='en')\n", + "print(\"Sample Report: \", sample)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [ "\n", "### Generate a single report\n", "\n", - "Use the `generate_report` method to generate a single report by specifying a single object ID in the `where` parameter. Since there was only one report template associated with the survey the index of 0 is used. \n", + "Use the `generate_report` method to generate a single report by specifying an object ID in the `where` parameter. In the cell below, the index of 1 specifies the report template uploaded earlier in this notebook as the report template to use when generating the report.\n", "\n", "The `where` clause follows the same format as the `where` parameter when querying a feature service layer. " - ], - "metadata": {} + ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\\Temp\\Water%20Quality%20Inspection_OID122.docx\n" + ] + } + ], "source": [ - "report = survey_by_id.generate_report(templates[0], where=\"objectid=122\")\r\n", + "report = survey_by_id.generate_report(templates[1], where=\"objectid=122\")\n", "print(report)" - ], + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Generate a report as a PDF\n", + "\n", + "Specify `pdf` as the `output_format` to print the report as a PDF document. If the `output_format` parameter is omitted the report will default to a Microsoft Word DOCX file." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ - "/tmp/Water_Quality_Inspection_report_e68c44.docx\n" + "Single report as PDF: \\Temp\\Water%20Quality%20Inspection_OID1.pdf\n" ] } ], - "metadata": {} + "source": [ + "pdf_report = survey_by_id.generate_report(templates[1], where=\"objectid=1\", output_format=\"pdf\")\n", + "print(\"Single report as PDF: \", pdf_report)" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", "### Generate multiple reports\n", "\n", - "If you are looking to generate reports for multiple object IDs in the survey you can specify `\"objectid=1 OR objectid=2\"` to generate reports for those two features. Alternatively, omitting the `where` clause will result in reports created for all features in the feature service. In either scenario the output is saved as a ZIP file, and will be stored locally on disk if run through a Jupyter Notebook. " - ], - "metadata": {} + "To generate reports for more than one survey record, specify multiple object IDs in the `where` clause, for example, `\"objectid=1 OR objectid=2\"`. Alternatively, omit the `where` clause to generate reports for all features in the feature layer. In both scenarios the output is saved as a ZIP file that will be stored locally on disk when run from a Python notebook.\n", + "\n", + "In the example below, the `where` clause queries the feature layer to return records where a water station advisory was enacted after January 1, 2020. Any records that match the query will be included in the report. You can create a dynamic `where` clause that can query records for the last week, month, or year for example as well as add additional criteria from the data to create your reports. " + ] }, { "cell_type": "code", - "execution_count": 6, - "source": [ - "batch_reports = survey_by_id.generate_report(templates[0])\r\n", - "print(batch_reports)" - ], + "execution_count": 11, + "metadata": {}, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ - "/tmp/Water_Quality_Inspection_report_7a8ea1.zip\n" + "Local batch reports: \\Temp\\ReportPackageNamePython.zip\n" ] } ], - "metadata": {} + "source": [ + "local_batch_reports = survey_by_id.generate_report(templates[1], where=\"ws_advisory = 'Yes' and ws_advisory_start_date > '01/01/2020'\", \n", + " report_title=\"SingleReportInstance\", package_name=\"ReportPackageNamePython\")\n", + "print(\"Local batch reports: \", local_batch_reports)" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", - "### Generate multiple reports and save to your organization as an item\n", - "\n", - "To generate reports and save them in your ArcGIS organization content, add the `report_title` argument. By specifying a `report_title` the reports are saved in your content as a code sample, which is available for download as a ZIP and viewed on a desktop.\n", + "### Generate multiple reports and save to your organization\n", "\n", - "
This parameter is required in order to upload your report to your organization. However, the name of your report or code sample will default to survey_name_report_unique_ID.
\n", + "To generate reports and save them in your ArcGIS organization content, add the `folder_id` argument. By specifying a `folder_id` the reports are saved in your content as a code sample, which is available for download as a ZIP file.\n", "\n", "The code sample can then be shared to a group or publicly so that others can download the ZIP and view the reports." - ], - "metadata": {} + ] }, { "cell_type": "code", - "execution_count": 7, - "source": [ - "import datetime\r\n", - "nowstring = datetime.datetime.now().strftime(\"%Y%m%d%H%M%S\")\r\n", - "batch_reports = survey_by_id.generate_report(templates[0], report_title=\"Test_{0}\".format(nowstring))\r\n", - "print(batch_reports)" + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Org batch reports: \n", + "Search result: []\n" + ] + } ], + "source": [ + "import datetime\n", + "from datetime import date, timedelta\n", + "nowstring = datetime.datetime.now().strftime(\"%Y%m%d%H%M%S\")\n", + "prev_days = date.today() - timedelta(7)\n", + "folder_ID = survey_by_id.properties['ownerFolder']\n", + "org_batch_reports = survey_by_id.generate_report(templates[1], where=\"CreationDate > '{}'\".format(prev_days),\n", + " package_name=\"Test_{0}\".format(nowstring), folder_id=folder_ID)\n", + "print(\"Org batch reports: \", org_batch_reports)\n", + "search_for_batch_reports = gis.content.search(\"Test_{0}\".format(nowstring))\n", + "print(\"Search result: \", search_for_batch_reports)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Generate a report with all possible parameters\n", + "\n", + "The example below demonstrates all possible parameters that can be used in the `generate_report` method. Most of these parameters are listed in the description of the `create_sample_report` method, covered earlier in this notebook. Additional parameters that can be used with the `generate_report` method are as follows:\n", + "\n", + "- `package_name`—Define the name of the ZIP file or code sample that is created if multiple reports are generated.\n", + "- `output_format`—Specify the file format for the report output. Accepted values are `docx` and `pdf`.\n", + "- `folder_id`—Upload the report to a specific folder in your ArcGIS organization." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, "outputs": [ { + "name": "stdout", "output_type": "stream", + "text": [ + "All params: \n" + ] + } + ], + "source": [ + "folder_ID = survey_by_id.properties['ownerFolder']\n", + "webmap = gis.content.search(query=\"title:Water Quality Inspection Web Map\", item_type=\"Web Map\")\n", + "wm_item=webmap[0]\n", + "all_params = survey_by_id.generate_report(templates[1], where=\"ws_advisory = 'Yes' and ws_advisory_start_date > '01/01/2020'\", utc_offset=\"-07:00\", report_title=\"All_Params_Report\",\n", + " package_name=\"All_Params_Package\", output_format=\"pdf\", folder_id=folder_ID, \n", + " merge_files=\"none\", survey_item=survey_by_id, webmap_item=wm_item, \n", + " map_scale=\"10000\", locale=\"en\")\n", + "print(\"All params: \", all_params)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Update report template\n", + "\n", + "Report templates may need to be updated to incorporate changes to a survey, or to modify the page layout, text formatting, and so on.\n", + "\n", + "Use the `update_report_template` method to programmatically update existing report templates associated with a survey. This is particularly useful if you need to bulk update the templates for various surveys in your organization. The `update_report_template` method first checks the syntax of the updated template file. If the check is successful, the method updates the existing item in your organization with the new template. If the check is unsuccessful an error message is returned." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "scrolled": true + }, + "outputs": [ + { "name": "stdout", + "output_type": "stream", "text": [ - "\n" + "[]\n" ] } ], - "metadata": {} + "source": [ + "updated_template = r\"\\Temp\\PythonAPITemplate.docx\"\n", + "update = survey_by_id.update_report_template(updated_template)\n", + "print(update)" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\n", "### List saved reports\n", "\n", - "Finally, use the `reports` property to list the reports stored in the ArcGIS organizational account from the current GIS connection. This shows all reports that are saved in that named user's content." - ], - "metadata": {} + "Finally, use the `reports` property to list the reports stored in the ArcGIS organizational account for the current GIS connection. This will return all reports that are saved in that named user's content." + ] }, { "cell_type": "code", - "execution_count": 8, - "source": [ - "recentReports = survey_by_id.reports\r\n", - "p = [print(t.title) for t in recentReports]" - ], + "execution_count": 15, + "metadata": {}, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "Manhole_Inspection_report_7844e0\n", - "Tree_Health_Survey_statistic.docx\n", - "Tree Health Survey - Summary table\n", - "Tree_Health_Survey_sampleTemplate_summarytest1.docx\n", "Test_summary1\n", - "UC2020 Hydrants Maintenance_OID_summary1\n" + "UC2020 Hydrants Maintenance_OID_summary1\n", + "UC2020 Hydrants Maintenance_5 records_20201211002634\n", + "Daily Fish Log_sampleTemplateSummaryIndividual\n", + "Manhole Inspection sample template\n" ] } ], - "metadata": {} + "source": [ + "recentReports = survey_by_id.reports\n", + "p = [print(t.title) for t in recentReports]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -266,9 +527,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.9" + "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} From c35806031cd2b9f967f43355c214d8351fef5e25 Mon Sep 17 00:00:00 2001 From: Zachary Sutherby Date: Tue, 17 Aug 2021 15:44:40 -0700 Subject: [PATCH 3/3] Update README.md --- Work with Reports/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Work with Reports/README.md b/Work with Reports/README.md index a50dcff..09acb7b 100644 --- a/Work with Reports/README.md +++ b/Work with Reports/README.md @@ -1,4 +1,4 @@ -# Working with Reports (Guide) +# Create reports using the ArcGIS API for Python (Guide) ArcGIS Survey123 reports are an effective way to quickly visualize, interpret, and share survey responses. Reports use a template you can personalize, that's applied to your survey results and shared as either a Microsoft Word or PDF document.