Button formula with 2 AddRow()'s & then OpenRow() the first row

Hi, very new to coda but enjoying the learning.

I have a button that I want to AddRow() one row to a table, modify a value on that row and also add one row to a related table and modify a value on that new row and then lastly use the OpenRow() to open that first table with a specific table view not used by the master table.

I have had success in creating a button that AddRow’s & modfies all the required rows but I’m not sure how to get the OpenRow() to open the view of the row created first, as gives me: " * 2 rows added

  • Layout specified is not valid for the row". And this is because it is pointing to the table of the second row that was created.

Formula

RunActions( 
  AddRow(
    [BASE Tasks],
    [BASE Tasks].[Quick description], "New Shop Drawing Review",
    [BASE Tasks].[Task type], "Shop Drawing Review"
  ).WithName(newTask,

      AddRow(
        [BASE Update Log],
        [BASE Update Log].Task, newTask,
        [BASE Update Log].Comment, "None"
      ).WithName(newTask2,
        RunActions(
      OpenRow(newTask2,[BASE Tasks],"modal")
    )
  )
)

)

I can also get it to create & modify all required rows as per above AND open the correct table view with openRow() but it creates an additional second unwanted row in the first table and this is the row it opens with OpenRow():

RunActions( 
  AddRow(
    [BASE Tasks],
    [BASE Tasks].[Quick description], "New Shop Drawing Review",
    [BASE Tasks].[Task type],"Shop Drawing Review"
  ).WithName(newTask,
    RunActions(
      AddRow(
        [BASE Update Log],
        [BASE Update Log].Task,newTask,[BASE Update Log].Comment, "None"
      ),
      OpenRow(newTask,[Shop drawing reviews],"modal")
    )
  )
)

This is what I hope the user ends up presented with:

Any suggestions would be much appreciated. And note I am a very green formula writer and not very familiar with coding.

Thanks in advance!

Hi @Nick_Genever

you are experiencing a double add beacuse you are using withname with an action, even if the result of the action is the reference of the added row.
You can do something like this

RunActions( 
  AddRow(
    [BASE Tasks],
    [BASE Tasks].[Quick description], "New Shop Drawing Review",
    [BASE Tasks].[Task type],"Shop Drawing Review"
  ),
  RunActions(
    AddRow(
      [BASE Update Log],
      [BASE Update Log].Task,[BASE Tasks].Last(),[BASE Update Log].Comment, "None"
    ),
    OpenRow([BASE Tasks].Last(),[Shop drawing reviews],"modal")
  )
)

Cheers
Arnhold

2 Likes

Thanks very much Felipe, this works!

Cheers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.