DEV Community

Cover image for Review an AI-generated Salesforce change: list what else runs on the same object
Juan Manuel Garrido
Juan Manuel Garrido

Posted on

Review an AI-generated Salesforce change: list what else runs on the same object

An AI model can draft a Flow, an Apex class or a validation rule in minutes. In a Salesforce org, that draft still has to live next to everything that already runs on the same object. Today I wrote on LinkedIn that experienced developers, in the teams I have worked with, often solved in 20 minutes a problem that took other people two days. Not because they typed faster. Because they already knew where to look, what to ask, and when to distrust a solution that looked clean.

This post is a practical way to do the "where to look" part before you ship an AI-generated change. It is not a substitute for a senior review. It is a way to arrive at that review with a list, not with a feeling.

The Spanish original is here: https://discover.egafutura.com/la-ia-y-el-developer-con-25-anos-de-experiencia/?utm_source=devto&utm_medium=referral&utm_campaign=amplify

1. Export the automation that already touches the object

Active flows, with regular SOQL:

sf data query --result-format csv \
  --query "SELECT ApiName, Label, ProcessType, Description, LastModifiedBy.Name, LastModifiedDate FROM FlowDefinitionView WHERE IsActive = true" \
  > flows.csv
Enter fullscreen mode Exit fullscreen mode

Active validation rules, with the Tooling API:

sf data query --use-tooling-api --result-format csv \
  --query "SELECT EntityDefinition.QualifiedApiName, ValidationName, Active, Description, ErrorMessage, LastModifiedBy.Name FROM ValidationRule WHERE Active = true" \
  > rules.csv
Enter fullscreen mode Exit fullscreen mode

Triggers (Tooling API):

sf data query --use-tooling-api --result-format csv \
  --query "SELECT Name, TableEnumOrId, Status, LastModifiedBy.Name FROM ApexTrigger WHERE Status = 'Active'" \
  > triggers.csv
Enter fullscreen mode Exit fullscreen mode

TableEnumOrId is the object for a trigger. For flows, the object is not always a dedicated field in FlowDefinitionView, so you will also scan ApiName, Label and Description. That is imperfect, and it is still better than opening every flow by hand in a large org.

2. Build a short list in pandas

Say the AI change touches Opportunity. A few lines of pandas give you a review agenda:

import pandas as pd

obj = "Opportunity"
flows = pd.read_csv("flows.csv")
rules = pd.read_csv("rules.csv")
triggers = pd.read_csv("triggers.csv")

mask = (
    flows["ApiName"].str.contains(obj, case=False, na=False)
    | flows["Label"].str.contains(obj, case=False, na=False)
    | flows["Description"].str.contains(obj, case=False, na=False)
)
flow_hits = flows.loc[mask, ["ApiName", "Label", "ProcessType", "LastModifiedBy.Name"]]

rule_hits = rules[rules["EntityDefinition.QualifiedApiName"] == obj][
    ["ValidationName", "Description", "ErrorMessage", "LastModifiedBy.Name"]
]
trig_hits = triggers[triggers["TableEnumOrId"] == obj][
    ["Name", "LastModifiedBy.Name"]
]

print("Flows that may run:", len(flow_hits))
print("Active validation rules:", len(rule_hits))
print("Active triggers:", len(trig_hits))
Enter fullscreen mode Exit fullscreen mode

Paste those three tables into the ticket. The question for the reviewer is no longer "does this Flow work?". It is "what else will run when this record is saved?". A clean-looking change can collide with an old rule, loop with another flow, or overwrite a field that a batch still expects to find empty.

Managed package automation will also appear in some of these queries. If you only want what your team owns, filter out rows whose name or namespace you do not maintain. Keep the managed ones in a second list: you cannot edit them, but they can still fire after your change and surprise you.

Write the three tables into the ticket as CSV or as a pasted Markdown table. The next person who reviews the change should not have to run the queries again to see what you already saw.

3. Add the cases a model usually skips

I still want three tests next to that list, even if this post is about queries:

  • A record that must be blocked, with a clear error message.
  • A record that must go through, even if a field arrives later than the happy path assumes.
  • The same change run by a user who is not a System Administrator, so sharing and field-level security show up.

If the change touches a discount, an approval or a status, include the case where the usual approver is away. A process that only works in a demo with an admin will not survive a normal week.

4. When to slow down

None of this proves the change is wrong. It does justify waiting a day when:

  • The new Flow or class has no description, or the description repeats the API name.
  • The tests assert coverage, not the business rule (for example, that a discount over a cap is not saved).
  • The model invented a field or object for a value that already exists.

The model accelerates the draft. The list tells you where to look. Someone with experience still decides when that draft is not ready.

If your sales, stock and billing numbers have to come from the same place, that is what a native ERP on Salesforce is for. I also publish a longer Spanish version of the experience argument on EGA Futura Discover.

Top comments (0)