Please add a DoNothing() action

Sometimes in automations or on a button I want the option of

IF {Condition} THEN Addrow() ELSE **DoNothing()**

There are workaround like ResetControlValue([The Do Nothing Workaround Checkbox]).

But this is messy. It seems like it should be a simple quality of life feature for us doc editors and I would love to have it to clean up some of my more complex formulas.

Longer Example
I find this most necessary inside buttons and automations where several steps all happen at once based on complex rules. For example:

RunActions(
  IF({Condition}, Addrow(),          **DoNothing()**),
  IF({Condition}, ModifyRow(),       **DoNothing()**),
  IF({Condition}, SetControlValue(), **DoNothing()**),
  IF({Condition}, Notfiy(),          **DoNothing()**)
)
1 Like

Hi @Logan_Krantz,

There is _Noop()

2 Likes

_Noop() is hidden and unsupported, so it is not reccomended in production workflows.

But you can always just enter a NULL action using "" or '' .
In a RunActions() block this will have the same effect as _Noop().
So the ‘Longer Example’ above could be written…

RunActions(
  IF({Condition1}, Addrow(),         ""),
  IF({Condition2}, ModifyRow(),      ""),
  IF({Condition3}, SetControlValue(),""),
  IF({Condition4}, Notfiy(),          "")
)

(But in a non-action formula, it will return a BLANK item, which you might not want.)

The BEST way to do what you want is to use the SwitchIf() formula instead of If()
because the ELSE parameter is not needed.

So the ‘Longer Example’ above could be written…

RunActions(
  SwitchIf({Condition1}, Addrow(...) ),
  SwitchIf({Condition2}, ModifyRow(...) ),
  SwitchIf({Condition3}, SetControlValue(...), ),
  Switchif({Condition4}, Notfiy(...))
)

Or - more succinctly - if you know only ONE condition will be met…

SwitchIf(
    {Condition1}, Addrow(...),
    {Condition2}, ModifyRow(...),
    {Condition3}, SetControlValue(...),
    {Condition4}, Notfiy(...),
  )

with no need for the RunActions() formula.

I find myself using SwitchIf() far more often than If() for this very reason

Max

2 Likes

Hi Team, Thanks for all the responses.

Max your 1st example is great and probably the one I will be using in the future as it gives me the chance to comment my more complex code. For example:

RunActions(
  IF(
    {Condition1}, 
    // THEN do the thing
    Addrow(),
    // ELSE do nothing
    ""
  ),
  IF(
    {Condition2}, 
    // THEN do the thing
    ModifyRows(),
    // ELSE do nothing
    ""
  )
)

I decided to put a bit of a table together and test all the different methods. Here are my results.

There are a few interesting take aways.

  1. There are clearly many valid ways to ‘Do Nothing’

  2. In the past I used to get errors when trying to the
    IF(false(), RunActions(), "" /* Do nothing */ )
    However when preparing these tests I could not recreate those errors.

  3. The _Noop() formula has a nice popup that says ‘No Action Taken’.

1 Like

In Conclusion, While there are still many valid ways to ‘Do Nothing’ I would still love to see a ‘DoNothing()’ formula in the future. This has a few advantages over the current methods

  • We can get the benefit of _Noop() showing a nice popup without using an unsupported hidden formula.
  • It would make code more readable without the need for stringent commenting like I am currently doing. (See code block above)
  • Coda formula language is one of my favourite to code in. It has great quality of life enhancements like [My Value].IsEmpty() & .IsNotEmpty(). I would love to see a DoNothing() formula added to the list as one more quality of life enhancements.
1 Like

Yes, or update if function,
for use the if function without needing the do argement nothing, some tools offer it

_Noop() is the way; it’s a hidden formula but in fact that is the formula that Coda uses under the hood itself when there needs to be no action (e.g. for disabled buttons their formula would be a _Noop()). I’ve had SwitchIf with no trailing action, as well as the blank "" value fail me in the past, and only _Noop() worked consistently.

But I agree that Coda should alias the _Noop() with a DoNothing() function and make it official.

3 Likes

Hi Team, I found a common situation where you have to use _Noop(). Every other method discussed above results in errors.

This is true for anytime inside a ForEach() you want to conditionally perform an action.

I hope this usecase will help support the need for a DoNothing()

1 Like

We have it! The new ‘NoAction()’ coda formula. (Read more here)

Thanks for those in the community and the Coda team that made it happen!

2 Likes