Help with CurrentValue, custom Objects, and RunActions

Hey all,

Having a strange problem here.

I’m working with a custom pack formula SearchPeople that returns an Array of People objects, each of which have properties like Name, ID, etc.

I am trying to create a button that runs the formula and - for every result - adds a row to two separate tables.

My first attempt is this:

ForEach(SearchPeople([API Key], "test search" ,thisRow.Company.Website),
  if(NOT(CurrentValue.Id.In([!People].[Apollo.io ID])), runactions(
    AddRow([!People],[!People].Name, CurrentValue.Name, [!People].[Apollo.io ID], CurrentValue.Id),
    AddRow([INTERSECTION - Employment CompanyxEmployee], [INTERSECTION - Employment CompanyxEmployee].Company, thisRow.Company, [INTERSECTION - Employment CompanyxEmployee].Employee, [!People].Last())
  ),
    _NoOp())
   ))

But instead, I get the error

“Could not find Name reference in CurrentValue”

This is strange, however, because that reference certainly exists. And it’s certainly returned. If I modify the formula to just add ONE row to ONE table and dispense with RunActions

ForEach(SearchPeople([API Key], "test search" ,thisRow.Company.Website),
  if(NOT(CurrentValue.Id.In([!People].[Apollo.io ID])), 
    AddRow([!People],[!People].Name, CurrentValue.Name, [!People].[Apollo.io ID], CurrentValue.Id),,
    _NoOp())
   ))

It executes perfectly and adds the one row.

It seems to me like RunActions is preventing a reference to the CurrentValue from the For loop. Is this intended behavior, am I doing something funky,. or is there a bug at work here?

What’s the return type of your pack formula?

I recently created a pack formula that returns an array of objects, and when that formula is inputted into a Button along with ModifyRows, so that a column is modified with the output of the formula, each item in the result loses its structure.

Well - to be exact it doesn’t lose it’s actual structure, but Coda can’t recognize or chain into the values, instead I have to use ParseJSON() in place of chaining.

BUT when I run the formula on a column, Coda recognizes the structure of the object and then I can run a ForEach loop off that Column and chain out the individual values.

So for my solution, I extracted the Pack formula from the button and input it into its own column - then had the button run a ForEach loop off that column.

Hopefully that helps some! I can send Loom and screenshots if you need - but it’s honestly hard to pinpoint or dissect issues like this without seeing more context from your side

1 Like

Hi @Billy_Jackson,

Two things.

First, in your code you have:

[INTERSECTION - Employment CompanyxEmployee].Company, thisRow.Company

This is trying to set the value of the Company column in the new row of [INTERSECTION - Employment CompanyxEmployee] to itself? Should it be CurrentValue.Company?

Second is a potential workaround but also an improvement to how you are creating a row and referencing it that I think you should take on board going forwards.

You are using the formula [!People].Last() to reference the row you just created in People. This is not the preferred method, especially in a multi user environment as it can cause a conflict if more than one person runs the same type of action.

The method I use is to create the new row needed as the value for the reference cell.

For example, your code would look like this:

ForEach(SearchPeople([API Key], "test search" ,thisRow.Company.Website),
  if(NOT(CurrentValue.Id.In([!People].[Apollo.io ID])), 
  AddRow([INTERSECTION - Employment CompanyxEmployee], [INTERSECTION - Employment CompanyxEmployee].Company, thisRow.Company, [INTERSECTION - Employment CompanyxEmployee].Employee, AddRow([!People],[!People].Name, CurrentValue.Name, [!People].[Apollo.io ID], CurrentValue.Id))
  ,
    _NoOp())
   )
   

It creates the Row in [INTERSECTION - Employment CompanyxEmployee] first and then for the value of [INTERSECTION - Employment CompanyxEmployee].Employee where you are setting the link to the row in People, it creates the row using AddRow and Coda automatically puts this new row in as the reference.

Hope this helps

Dale

1 Like

@Scott_Collier-Weir That’s exactly the same return. An array of objects, and this is a great solve!
So - to clarify - you have a column that contains the returned Array of Objects, and a button that uses ForEach(ThatColumn, runactions(etc…))…

Are you calling ForEach on the column itself, or how are you getting after it in there?

Ah yes Dale, I knew I was brain-farting something by having to resort to this! Your way is much better.

For your first question, it actually is thisrow.Company. This is a lite CRM function, so this is the OPPORTUNITY that i’m linking to the COMPANY that I’m also trying to link to PEOPLE. It’s too much!

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