I have a python script which I am using to automate an otherwise tedious serious of intersects, joins and calculate fields. As part of this, I am calculating a field, DF_Sev, which is reliant upon a field which will be from one of the intersect functions (call it Field B). Field B is not guaranteed to have the same name each time this script is run, and is therefore stored as a variable. However, within the calculate field function for DF_Sev, the variable for Field B is not recognized within the arcade expression i am using. Is there a way for this field to be passed to the arcade expression, or do i need to find another workaround?
Try using an F string
fieldVar = [f.name for f in arcpy.ListFields(fc)][0] # or whatever
arcEx = f"Text($feature.{fieldVar}) + "\n" + $feature.OBJECTID)
I was able to get around it by switching to a python expression, but I'll give this a shot as well!