Using the command below
survey_by_id.generate_report(report_template=choice, report_title="Report",where=f"objectid = {ob}", output_format="pdf")
I was able to generate survey123 report using ArcGIS Pro 3.0 when switched to ArcGIS Pro 3.1.3 the code fails and return the following error
File "D:\Inspection_report\survey_report.py", line 33, in rep_gen
survey_by_id.generate_report(report_template=choice, report_title="Report",where=f"objectid = {ob}", output_format="pdf")
File "C:\Users\MFarhat\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\apps\survey123\_survey.py", line 353, in generate_report
fl_url = self._stk_url
AttributeError: 'Survey' object has no attribute '_stk_url'
any idea on how to solve the issue?
Did you ever find a solution to this?
I'm also facing this issue and haven't figured it out yet. @ZacharySutherby any advice?
Did you find any solutions @MattLayman or @Aymen_Farhat ? Any insights would be much appreciated. I'm running into the same issue.
Not yet. I went ahead and added a separate thread to Geonet in the hopes that someone from ESRI will respond...
Hey guys,
I think we found an answer to this. If you dive into the underlying arcgis api code, it gets into this buggy pathway when the user you are signed in with in the python code is different than the user who owns the item in AGOL. If you make those users one and the same it will run fine. Here is what my code looked like... very simplified for this form. Hope this helps.
TLDR:
Make sure the owner of the form is the same user that you sign into with your python code
from arcgis.gis import GIS, Item
from arcgis.apps.survey123 import Survey, SurveyManager
gis = GIS("your_url", "your_username", "your_password")
survey_manager = SurveyManager(gis)
item = gis.content.get("your_item_number")
survey = Survey(item=item, sm=survey_manager)
templates = survey.report_templates
pdf_report = survey.generate_report(templates[0], where="objectid=1", output_format="pdf")
print("Single report as PDF: ", pdf_report)
Thanks Nathan. Yes, I've found this to be the case, however, I want a user who is NOT the owner of the form to be able to run this script. No luck so far with getting ESRI to respond as to whether this is possible...