Does Coda have a way to create loops?

Say I want to be able to update a certain groups of rows with a button. Let’s say I have a list of subtasks, and when the main task is “Complete”, I want to change the status of all related subtasks to “Complete” as well.

MainTask-Table fields: MainTask-Name, MainTask-Status
SubTask-Table fields: SubTask-Name, Related-MainTask-Name, SubTask-Status

Normally, if coding something like this, I’d start out in MainTask-Table, find all rows in SubTask_Table with the right Related-MainTask-Name, go to the first row, update the SubTask-Status, then loop through all the other rows in the found set until I’m at the last row.

It looks like Coda has something similar with the FunctionMap function?

So if I have a button in the MainTask-Table that says “Mark SubTasks Complete”, how would I do that?

Is it possible to do this with a loop of buttons? Say, for example, I have a button that says “Mark SubTask Complete” in each row of the SubTask table. Then in the MainTasks table, have a button that automatically executes all the buttons in the related rows? Obviously, if there was a fixed number of buttons to push, I can just add in those buttons one at a time, but I don’t know how many subtasks there are for each main task.

Thanks!
– Maria

Can you do this with RunActions?

It looks like you might be able to select all related fields, have a button in each one that says “MarkCompleted”, then execute all those buttons at once with RunActions. Is that right?

Never mind. Looks like the ModifyRows function will update all selected rows at once.

(But I’m still interested in learning how to use RunActions and FormulaMap, and look forward to examples being posted here to help me learn how they work.)

Best,
Maria

You may want to look at FormulaMap as well.

FormulaMap (list, expression)

Copy link

Provided a list and a formula, returns a list where each item is passed through the formula.

INPUTS

list

A table, column, or list of values.

expression

The formula to transform every value in list. Use currentValue to reference the current item being evaluated. For example, an expression of “currentValue * 2” will double every item in the list.

List("Dog", "Cat").FormulaMap(Upper(CurrentValue))

⟶ [DOG, CAT]

2 Likes

Here’s an example:

5 Likes

Dear @shishir,

Thanks for this example, especially the "detail view of task with sub-table"creates many use cases.

Just my personal logic:

If total sub-tasks belonging to a main task is 'true" , the main task should be true, isn’t it :question:

Amicable,
//JP

Sure, depends on your business logic, but that’s easy to implement. You would just need to decide if having no subtasks also means that your task is complete.

1 Like