Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every Monday the automation reads the rules from the Rules tab of your sheet.

  2. It fetches your open opportunities from Salesforce with the fields those rules mention.

  3. Each deal is checked against every rule.

  4. The Findings tab is cleared and refilled with every breach and a link to the deal.

  5. 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

RunsWeekly
Audit open deals against rules kept in a sheettoday, 9:00Succeeded
Email · Deal auditDeal audit: 7 issues across 92 open deals https://docs.google.com/spreadsheets/d/...

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
deal_audit_against_rules_kept_in_a_sheet.pyexample
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?
One rule per row on the Rules tab: a name, the Salesforce field API name, a check (max, min or required) and the limit. For example: Discount cap | Discount__c | max | 20.
Can it check rules that need judgement?
Yes. Ask for an AI check on text rules, such as whether the next step names a date, and it will read those fields for you.
Does it change anything in Salesforce?
No. It only reads opportunities and writes to your sheet.
What permissions does it need?
sheet edit; api read. Nothing else in your accounts is used.
Does it need AI?
No, but you can ask for an AI step (for example a summary). It then uses ClickRuntime's built-in AI allowance.
How many runs does it use?
One run each time it runs (weekly). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.