Hi Greg,
The code below shows how you could update the filter for a FeatureService with 1 FeatureLayer in its collection.
It could be expanded to multiple layers within the collection if needed using a loop.
Just modify the Username, Password, and the title of the FeatureService to modify.
Take a look and let me know how it goes.
Thanks,
Jeff
import copy,json
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "<USERNAME>", "<PASSWORD>")
srcResults = gis.content.search("title:ServiceAreas",item_type = "Feature Layer")
featCollection = srcResults[0]
#update a featurecollection layer filter
featCollD = featCollection.get_data(try_json=True)
#make a copy to manipulate the properties
featCollDCopy = copy.deepcopy(featCollD)
sql = 'ServArNu = 2'
#The code below assumes that 1 FeatureLayer was found within the collection
#Modify the number or loop on the layers for more
featCollDCopy['layers'][0]['layerDefinition']['definitionExpression'] = sql
#send the update to modify the Feature Layers within the FeatureCollection
featCollection.update(item_properties={'text':json.dumps(featCollDCopy)})