Update DB Table with API Results

Hi all,
I feel this should be something simple, but have read a lot of posts and docs and don't see an solution to my case. I have about 95% of the pieces in place to make this overall app work but am stuck.

Situation
I have a table of weekly time allocations by Jira Key name (text). Each allocation has a Key Name. I can query the Jira API to get all the IDs using a JS *return Promise.all(... *

This I can use to populate a table with the correct numeric IDs from this JS script:

Goal
My goal is to update the table 'allocations' with the project_id, so that downstream I can call Tempo search API passing in accountID (which I have) and project_id (and from/to)

Issue
I created a Bulk Update via Primary Key resource, using id as pk. However, the values of project_id are null (these are the only values I need to update actually).

Any help greatly appreciated - working on selling retool internally as I see so much promise for our org!

Nick

Hey @nickaus!

Where are you currently at with this issue? It looks like you might want to modify the underlying data for the table before passing it in instead of using the mapped value (which is more display only). I'd typically recommend doing so using a SQL join in a Query JSON with SQL resource but it can also be done using the Promise pattern you already have :thinking:

const modifiedData = testData.data.map(async (row) => {
  const additionalData = await dummyQuery.trigger({
    additionalScope: { userName: row.name },
  });
  return { ...row, addedProperty: additionalData.addedProperty };
});

return Promise.all(modifiedData);

Curious to know how you're approaching this!

Hi @Kabirdas
Thanks for your reply. I've moved forward a fair bit since this post. In places I'm using a transformer something like:

var arr = {{ ax_getWorkLogsbyProject.data }}

const res = arr.flatMap(({ results }) => results);

return (res)

... to 'flatten' the response data, then in some processes saving to either temporary or permanent storage in the Retool DB.

your other reply here was also super helpful for what I'm doing.

Thanks!
Nick

2 Likes