I have a model which needs to only produce 1 final report but is dependent on whether a variable is provided.So there are 2 different flows following on from that selection
Something like this, a policy number can be provided or not, if it is 1 report is generated (output2) if its not(output)
A python script has been saved as a geoprocessing tasks with the 2 outputs to feed into different chains of the model.
My script within the processing tool is:
import arcpy
input_data = arcpy.GetParameterAsText(0)
policynumber = arcpy.GetParameterAsText(1)
if policynumber == '':
output = arcpy.SelectLayerByAttribute_management(input_data, 'NEW_SELECTION')
else:
output2 = arcpy.SelectLayerByAttribute_management(input_data, 'NEW_SELECTION', "PolicyNumber = '{}'".format(policynumber))
arcpy.SetParameterAsText(2, output)
arcpy.SetParameterAsText(3, output2)
I am getting the error that 'output' is not defined.
Is this because I've built the second output into the IF statement?
How can I fix it?
Is there a better/easier way to generate a different report dependent on whether a selection has occurred?