Send Files to Coda from one Doc to another via WebHook

Ok. I have it working with this:
RunActions(ModifyRows(thisRow, thisRow.Done, true, thisRow.Completed, Today()), [Another Webhook Trigger]::SendWebhook(“URL”, “secret”, Object(“Name”, Concatenate("Task: ", Hyperlink(thisRow.ObjectLink(), thisRow.Task))._Merge(), “TagCategory”, thisRow.Category, “Tags”, thisRow.Tags, “Notes”, thisRow.Notes._merge(), “File”, ParseJSON(thisRow.File._Merge().ToText().First(), path: “$.publicUrl”).Hyperlink() )))

This will save a “Task” from one doc as a “Note” in another doc and it will pick up the FIRST file in the task and save it in the Note.

QUESTION:

How can I modify this to get all files saved in the task to save in the Note? Is this possible via webhook?

I tried adding a ForEach around the

ParseJSON(thisRow.File._Merge().ToText().First(), path: “$.publicUrl”).Hyperlink()

But it failed. Not sure if I wrote it wrong or it just can’t handle multiple files.

I’m afraid you just shared a secret token, you should probably delete that one unless you altered it

It would be easier to help you if you made a doc explaining your desired result :slight_smile:

Thank you for noticing that. I honestly didn’t even look at the formula I was posting, trying to do too many things at once. Changed it now. THANK YOU!!!

1 Like

Yes, but that would require setting up the automations again, setting up the webhook, etc. I don’t have time to do all that right now. It all works except I’m trying to send multiple files from one record in one doc to another record in another doc. I can send the FIRST() file but I can’t figure out how to have it run through and send all the files. I’m wondering if that’s a limitation with webhooks and not worth my time trying to figure it out.

Ah gotcha, it should be possible to send multiple “files”!

If you try extracting these file URLs, join them with a delimiter, maybe a comma, send this whole string, then split the received string on the same delimiter you should end up with a list of file URLs!

I sorted went down that road. I did a ForEach for the files but I didn’t use a “join” to put them back together. I wasn’t quite sure how to handle multiple URLs once I could create them. I tried, listcombine() which failed. Probably because it was a list and not a string. I’ll try using join and see what happens. Thanks!

Oh okay, I suggest breaking the problem down into smaller pieces! Here’s how you can do the ForEach part, the trick is to use _Merge() on each file, not all files at once :slight_smile:

thisRow.Files.ForEach(CurrentValue._Merge().ToText().ParseJSON("publicUrl")).Join(LineBreak())

Well I thought that looked good, but using that nothing gets uploaded to the File in the Destination doc. I’m wondering if something has to change on the webhook in the destination to allow for receiving more than one piece of data in that column? Sending one file works. But all my tests trying to do multiple just sends nothing. No errors generated. The doc is sending and the other is receiving but when trying to do multiple files the Files column is just empty.

I had the same issue and I solved it using a helper table in the destination doc.
Instead of sending the files itself, I send a list of their URLs to the destination doc. There I copy, using automation, each url to a row in a file column of the helper table. This will upload all files.Then I copy the files back using listCombine() to the destination table.

If you need some help to set it up, I’ll try to create a mock doc in my free time.

Now that’s a great idea. So basically just turn the files into their hyperlinks, pass a list of hyperlinks to another table (or possibly even to the same table in a different column) then automate copy/paste into the file column. I’ll give that a try in a bit and see if I can make that work.

1 Like

I’m glad you like it.

Bellow is an unedited automation formula that I use in my Doc. It’s a big one and in Portuguese… Maybe it can help you. You’ll see that it’s even possible to copy a look up column to another Doc using UIDs.

RunActions(
  [DB Peças]
    .AddRow(
      [DB Peças].[Backup UID],
      thisRow.[Step 1 Result].ParseJSON("$.Peça UID"),
      [DB Peças].Item,
      thisRow.[Step 1 Result].ParseJSON("$.Item"),
      [DB Peças].[Sigla (continuação)],
      thisRow.[Step 1 Result].ParseJSON("$.Sigla (continuação)"),
      [DB Peças].[Último extra],
      thisRow.[Step 1 Result].ParseJSON("$.Último extra"),
      [DB Peças].Extra,
      thisRow.[Step 1 Result].ParseJSON("$.Extra"),
      [DB Peças].[Descrição],
      thisRow.[Step 1 Result].ParseJSON("$.Descrição"),
      [DB Peças].Medidas,
      thisRow.[Step 1 Result].ParseJSON("$.Medidas"),
      [DB Peças].[Estado da peça],
      thisRow.[Step 1 Result].ParseJSON("$.Estado da peça"),
      [DB Peças].[Observação],
      thisRow.[Step 1 Result].ParseJSON("$.Observação"),
      [DB Peças].Link,
      thisRow.[Step 1 Result].ParseJSON("$.Link"),
      [DB Peças].[Na casa do cliente],
      thisRow.[Step 1 Result].ParseJSON("$.Na casa do cliente"),
      [DB Peças].Revisado,
      thisRow.[Step 1 Result].ParseJSON("$.Revisado"),
      [DB Peças].[Comissão],
      thisRow.[Step 1 Result].ParseJSON("$.Comissão"),
      [DB Peças].[Valor de contrato],
      thisRow.[Step 1 Result].ParseJSON("$.Valor de contrato"),
      [DB Peças].[Valor sugerido],
      thisRow.[Step 1 Result].ParseJSON("$.Valor sugerido"),
      [DB Peças].[Valor vendido varejo],
      thisRow.[Step 1 Result].ParseJSON("$.Valor vendido varejo"),
      [DB Peças].[Valor vendido],
      thisRow.[Step 1 Result].ParseJSON("$.Valor vendido"),
      [DB Peças].[Venda leilão recebida],
      thisRow.[Step 1 Result].ParseJSON("$.Venda leilão recebida"),
      [DB Peças].[Pago acerto],
      thisRow.[Step 1 Result].ParseJSON("$.Pago acerto"),
      [DB Peças].[Pago (crédito,  despesa)],
      thisRow.[Step 1 Result]
        .ParseJSON(
          "$.Pago crédito , despesa"
        ),
      [DB Peças].[Leilãos cadastrados],
      thisRow.[Step 1 Result].ParseJSON("$.Leilãos cadastrados"),
      [DB Peças].[Data de cadastro],
      thisRow.[Step 1 Result].ParseJSON("$.Data de cadastro"),
      [DB Peças].[Data da venda],
      thisRow.[Step 1 Result].ParseJSON("$.Data da venda"),
      [DB Peças].[Data do acerto/devolução],
      thisRow.[Step 1 Result]
        .ParseJSON(
          "$.Data do acerto/devolução"
        ),
      [DB Peças].[Tipo de leilão],
      [DB Tipos para leilão]
        .Filter(
          Tipo =
            thisRow.[Step 1 Result].ParseJSON("$.Tipo (número)")
        )
        .First(),
      [DB Peças].Cliente,
      [DB Clientes]
        .Filter(
          UID =
            thisRow.[Step 1 Result].ParseJSON("$.Cliente UID")
        )
        .First(),
      [DB Peças].Venda,
      [DB Vendas/Orçamentos]
        .Filter(
          UID =
            thisRow.[Step 1 Result].ParseJSON("$.Venda UID")
        )
        .First(),
      [DB Peças].Acerto,
      [DB Acertos]
        .Filter(
          UID =
            thisRow.[Step 1 Result].ParseJSON("$.Acerto UID")
        )
        .First(),
      [DB Peças].[Devolução],
      [DB Devoluções]
        .Filter(
          UID =
            thisRow.[Step 1 Result].ParseJSON("$.Devolução UID")
        )
        .First(),
      [DB Peças].[Status na loja],
      [DB Status na loja]
        .Filter(
          UID =
            thisRow.[Step 1 Result].ParseJSON("$.Status na loja UID")
        )
        .First(),
      [DB Peças].[Prestador de serviço],
      [DB Prestadores de serviço]
        .Filter(
          UID =
            thisRow.[Step 1 Result]
              .ParseJSON(
                "$.Prestador de serviço UID"
              )
        )
        .First()
    ),
  [Auxiliar para restaurar fotos].DeleteRows(),
  thisRow.[Step 1 Result].ParseJSON("$.URLs").ListCombine()
    .FormulaMap(
      [Auxiliar para restaurar fotos]
        .AddRow(
          [Auxiliar para restaurar fotos].Foto, CurrentValue
        )
    ),
  [DB Peças]
    .Filter(
      [Peça UID] =
        thisRow.[Step 1 Result].ParseJSON("$.Peça UID")
    )
    .First()
    .ModifyRows(
      [DB Peças].Fotos,
      [Auxiliar para restaurar fotos].Foto.ListCombine()
    ),
  [DB Acertos]
    .Filter(
      UID =
        thisRow.[Step 1 Result].ParseJSON("$.Acerto UID")
    )
    .First()
    .ModifyRows(
      [DB Acertos].Arquivado, false
    )
)

Wow! Amazing wish I could read Portuguese. Quick question. Ok. So I can send the data to a different column just as text, turn it into a hyperlink over in the destination. But how do you get it to take the hyperlink and actually upload the file? If I just copy/paste the hyperlinks into the File column, I don’t get files. :sob:

First you have to check if you really have a list of hyperlink in your destination column . Some webhooks packs only send text. When you copy the hyperlink to the helper table it should upload automatically the files. I translated part of my formula bellow:

RunActions(
[Helper Table].DeleteRows(),
  thisRow.[Step 1 Result].ParseJSON("$.URLs").ListCombine()
    .FormulaMap(
      [Helper Table]
        .AddRow(
          [Helper Table].File Column, CurrentValue
        )
    )
)

Sorry I don’t know JSON so this is all greek to me. I sent the info from the Source doc just as text to the Destination doc. Then I used a column to split the text and turn them into a list of hyperlinks. That way I didn’t have to worry about what the WebHook was sending. So I have a list of links in a field but if I copy that list of links, nothing happens in the File column. I was just testing with a button to copy the links and if I get that working, then I’d make the automation to do it for me.

Well, I broke it down even further and just copied/pasted 1 url manually and I get an error that says the URL path is too long.

So. That might be why it’s not working. So I need to figure out how to get the file URL properly so it isn’t such a long name.

Check this doc bellow. You can make a copy of it.

Thank you for this. However, if I put 2 files in the top table in the same Files field then click the button, I do get 2 rows in the helper table, but only the first file is copied into the first row and the second row is blank.

And. When I put a file into the first table, the calculated column is NOT calculating. I’ve never seen this happen. If I edit the column calculation, then save it, it will calculate.

Hmmm. This works for you?

Take a look at the post bellow… It’s tricky to deal with files or images

Wow. Thanks. That is kinda bizarre behavior.