Weekly
Audit open deals against rules kept in a sheet
Every Monday, open Salesforce deals are checked against the rules in your Google Sheet and every breach is listed on a Findings tab.
- Runs
- Weekly
- Apps
- Google Sheets, Salesforce
- AI
- Optional
- Access
- sheet edit; api read
Send this to your assistant
Create a ClickRuntime automation: every Monday, check open Salesforce opportunities against the rules in my Rules tab and write every breach to the Findings tab, then email me a summary.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Revenue operations owns the rules: maximum discount by deal size, required fields at each stage, minimum contract length. The rules change every quarter, and they're written in a sheet that sales leadership signs off. Checking deals against them by hand takes a day each month.
This automation reads the rules straight from that sheet every Monday and checks every open deal against them. Breaches go onto a Findings tab, and you get an email when it's done. Change a rule in the sheet and next week's audit uses it.
What you get out of it
Rules live where they're agreed
Leadership edits the rules in the sheet; nobody has to change the automation when policy changes.
A complete weekly audit
Every open deal is checked, not a sample, and the Findings tab is rebuilt fresh each week.
Easy to share and filter
Findings are a plain table with deal, owner, rule, value and link, ready to filter by owner or rule.
A Monday summary
The email tells you how many issues were found across how many deals, with a link to the sheet.
How it works
What happens, step by step
Every Monday the automation reads the rules from the Rules tab of your sheet.
It fetches your open opportunities from Salesforce with the fields those rules mention.
Each deal is checked against every rule.
The Findings tab is cleared and refilled with every breach and a link to the deal.
You get an email with the number of issues found.
Before it runs live
- Connect your Google Sheets account and pick the spreadsheets it may use
- Connect Salesforce
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Change what the AI looks for, or how it writes the result
- Add another app, for example also send it to Slack
- Combine it with other Google Sheets and Salesforce steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, notify
SHEET_ID = "your-spreadsheet-id"
INSTANCE = "https://yourcompany.my.salesforce.com"
API = f"{INSTANCE}/services/data/v61.0"
CHECKS = {"max": lambda v, x: v is not None and float(v) > float(x),
"min": lambda v, x: v is not None and float(v) < float(x),
"required": lambda v, x: v in (None, "")}
@on_trigger
def run(event):
sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")),
cache_discovery=False).spreadsheets()
rules = sheets.values().get(spreadsheetId=SHEET_ID, range="Rules!A2:D").execute().get("values", [])
fields = sorted({r[1] for r in rules})
headers = {"Authorization": f"Bearer {credentials.connection('salesforce', 'work')}"}
opps = http.get(f"{API}/query", headers=headers, params={"q": f"SELECT Id, Name, Owner.Name, {', '.join(fields)} "
"FROM Opportunity WHERE IsClosed = false LIMIT 500"}).json()["records"]
findings = [["Deal", "Owner", "Rule", "Value", "Link"]]
for o in opps:
for name, field, check, limit in [(r + ["", "", "", ""])[:4] for r in rules]:
if CHECKS[check](o.get(field), limit):
findings.append([o["Name"], o["Owner"]["Name"], name, str(o.get(field)), f"{INSTANCE}/{o['Id']}"])
sheets.values().clear(spreadsheetId=SHEET_ID, range="Findings!A:E").execute()
sheets.values().update(spreadsheetId=SHEET_ID, range="Findings!A1", valueInputOption="RAW",
body={"values": findings}).execute()
notify.email_me(f"Deal audit: {len(findings) - 1} issues across {len(opps)} open deals",
f"https://docs.google.com/spreadsheets/d/{SHEET_ID}")
return {"deals": len(opps), "findings": len(findings) - 1}FAQ
Common questions
How do I write a rule?
Can it check rules that need judgement?
Does it change anything in Salesforce?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Build a white-space table of what key accounts haven't bought
Each month, a Google Sheet shows every key account against your product list, marking what they own and counting the gaps.
See how it worksLog review sentiment in a sheet and open cases for bad ones
New customer reviews are labelled positive, neutral or negative in a Google Sheet, and negative ones become Salesforce cases.
See how it worksGet realistic close dates for open deals
Every week, AI estimates a realistic close date for each open deal, saves it in Salesforce and logs the old and new dates in a sheet.
See how it worksKeep exploring
Set up “Audit open deals against rules kept in a sheet” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.