Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option for trigger formulas to trigger only on changes to existing records #1407

Open
aeshna-cyanea opened this issue Jan 29, 2025 · 4 comments

Comments

@aeshna-cyanea
Copy link

aeshna-cyanea commented Jan 29, 2025

Describe the problem to be solved

currently, trigger formulas always proc on new records, no way to untick the "trigger on new" checkbox when selecting triggers. Alternatively, fix it so that the formula only triggers only if the new record has non-empty columns that the formula is watching.

Describe the solution you would like

UI change to let us disable new record triggers, or a fix to disable triggers when there are no matching columns in the newly created record

@hjhp
Copy link

hjhp commented Feb 19, 2025

This would be a huge improvement. I have just migrated a pricing spreadsheet and one thing I'd love to add is a column that looks up market prices by API; at the moment this is not realistic because the options to limit when/how a formula is evaluated are too limited. (For example, there is no point calling a price lookup API upon record creation — you should wait at least until product name has been filled in — and I don't want the lookup to happen all the time, only when I change some defined field e.g. "market price date").

@dsagal
Copy link
Member

dsagal commented Feb 22, 2025

Could you share examples of particular use cases? Many, I believe, are possible today.

The basic idea is that a trigger formula can itself contain conditions. If the issue is that it shouldn't trigger for a new record when it has missing data, then you can check for missing data in the formula.

For @hjhp's example, let's say you want some action called only when column Date or Stock is changed, and not on new records if the Date or Stock column is blank. You can achieve that with a trigger formula that triggers on changes to Date and Stock columns, with the formula like:

if $Date and $Stock:
  return getPriceForDate($Stock, $Date)
else:
  return None

(Note that fetching external data, as in this example, isn't properly supported; though may be attempted by self-hosters by enabling the experimental REQUEST function.)

@hjhp
Copy link

hjhp commented Feb 22, 2025

Interestingly it hadn't really occurred to me to reverse the "forced" trigger-on-create behaviour via an if-statement.
Perhaps the question is more philosophical/UI-related: if a checkbox can never be unchecked, should it be presented as a checkbox?

@dsagal could you also please clarify this (slightly tangential): let's say I put your formula into a field called "market_price". If I wanted to modify your if-statement to check that market_price was not already filled in, would I have to use PEEK(), e.g. if $Date and $Stock and not PEEK($market_price)?

@aeshna-cyanea
Copy link
Author

aeshna-cyanea commented Feb 22, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants