Dynamic Report Title with API for Python

248
2
Jump to solution
03-22-2024 11:31 AM
JamesTurner2
New Contributor III

I'm following this guide to create a script to generate batches of reports: https://developers.arcgis.com/survey123/guide/create-reports-using-the-arcgis-api-for-python/

Is there a way to incorporate dynamic report titles from the survey results? When I create the reports in the web app, I use ${unique_form_id} as the report title. I can't seem to find a way to do that with the generate report function. If I can't control the name of the report, I'm not sure this is going to work for me.

0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @JamesTurner2

You can use the report_title parameter for the generate_report() method to specify your individual report title(s) and within that string you can include your dynamic values. For example, you can set the report_title to "Report for ${unique_form_id}" and the value for the dollar sign curly bracket reference will be dynamically populated with the value from the record. The key with this is you won't be able to use python's format string capability unless you escape the curly brackets. 

Thank you,
Zach

View solution in original post

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @JamesTurner2

You can use the report_title parameter for the generate_report() method to specify your individual report title(s) and within that string you can include your dynamic values. For example, you can set the report_title to "Report for ${unique_form_id}" and the value for the dollar sign curly bracket reference will be dynamically populated with the value from the record. The key with this is you won't be able to use python's format string capability unless you escape the curly brackets. 

Thank you,
Zach
0 Kudos
JamesTurner2
New Contributor III

Thanks @ZacharySutherby I guess I should have just tried it! I couldn't find anything in the documentation about this or in the forums. Luckily I only need the attribute value for the name, so I don't need to get into format strings within the title.

I had planned to work around this by exporting one report at a time so I could use a variable in the report title, but this is much faster and more efficient

0 Kudos