AnsweredAssumed Answered

Custom Geoprocessing Tool Reporting for ArcGIS online

Question asked by rralbritton on Jan 19, 2016
Latest reply on Jan 20, 2016 by rralbritton

I've written a basic script that reads through a table stored in an SDE database and reports back on values within a particular field. If the field is equal to 'Report to Manager" the script fetches notes about the issue and includes it in the report. the report is just a simple text file.


I ran the tool on my computer and it runs fine, and then published it as a processioning service. I set one parameter - to let a user define an output directory, but this option does not appear on AGOL. If I execute the tool, it runs but there are no visible results.


How do I get this report to run within AGOL so that the user can get a txt or pdf of the requested report?


import arcpy, os
import time
from datetime import datetime
from datetime import date

arcpy.env.workspace = "C:\\Temp"
arcpy.env.overwriteOutput = True

def outName(input,post="_Output"):
    """Returns output name."""
    return outName

folder = arcpy.GetParameterAsText(0) #"C:\\Temp\\DDC_ReportSummary.txt"
inputfile = folder+"/DDC_ReportSummary.txt"
time =

infile = open(inputfile,'w')
infile.write("REPORT SUMMARY: "+str(date)+" "+str(time)+'\n\n')

StopsTable = "C:\\Temp\\DDC_Stops"
ReportsTable = "C:\\Temp\\DDC_Reports_Table"

#Get the status of all stops that where status = "OK" for the current date, recorded within the past 3 hours


for row in sc1:
    if row.Stop_Status == "OK":
        infile.write("Stop "+str(row.Stop_Number)+": "+row.Stop_Status+"\n")          
    del row
del sc1

#Get information on any stops that need to be reported to a manager
#In the Reports table, select all the records that have been recorded on the current date, wihtin the past 3 hours

infile.write("\nMANAGER ATTENTION REQUIRED\n\n")
sc2 = arcpy.SearchCursor(StopsTable)

for row in sc2:
    if row.Stop_Status =="Report to Manager":
        infile.write("Stop "+str(row.Stop_Number)+": "+row.Stop_Status+":")
        sc3 = arcpy.SearchCursor(ReportsTable)
        for line in sc3: 
            if line.Stop_Num ==row.Stop_Number:
            del line
        del sc3
    del row
del sc2