Curious if I could pick your brains on how to achieve the workflow:
I am connecting to an asset via API as well as another separate GIS Feature Class in an EGDB.
The workflow will start with a user editing the GIS Feature Class. When a user updates or creates a new record in the GRI_TEST1 Feature Class, I am pulling it into the Change Detector, and wanting to write to the API table only if the assetkey does not exist in the API table. The assetkey in the GIS FC = unitid in the API Table, as the field has a different name than the same column has in the GRI_TEST1 Feature class.
Would I be going the right route here in using the PythonCaller to achieve this? Right now my writer is writing to a xlsx document and not the API table yet so I could test out the logic.
# Import necessary modules
from fmeobjects import *
# Function to check if asset key exists in feature class
def assetkey exists(assetkey, feature_class):
# Implement the logic to query the GIS feature class
# Assume 'feature_class' is an object representing your GIS feature class
# 'assetkey' is the ID of the asset you're checking
# Example logic (replace with actual GIS query)
for feature in GRI_TEST1:
if feature.getAttribute('ASSETKEY') == assetkey:
return True
return False
# Initialize FME features and parameters
def main():
# Initialize FME objects
feature = FMEFeature()
# Get asset ID from input feature
assetkey = feature.getAttribute('ASSETKEY')
# Example feature class - replace with actual feature class access
feature_class = FMEFeature()
# Check if asset ID already exists in the feature class
if not assetkey_exists(assetkey, feature_class):
# Asset key doesn't exist, write the record to the feature class
feature_class.write(feature)
# Call the main function
main()
Would that be the correct idea? What about in cases where a user deletes a record in the GIS FC - would that be a separate python caller to handle the deletion cases?
Thanks so much.