Trigger API Workflow that adds data to two tables (one-to-many) for logging

Hi folks, having a tricky time figuring out the cleanest way to do this. Every path I’ve taken seems to run into challenges.

In short, I’m creating a logging system to track user activity.

TABLES:

Activity: contains standard info like User, Page, Activity, etc
Activity Data: contains any number of key-value pairs stored in two separate fields in the table

Activity is tied to Activity Data in a one-to-many relationship.

The trick is trying to figure out how to pass this data to API Workflow(s) in a relatively simple fashion.

I was going to send them individually (Activity, then each Activity Data) separately via an API Workflow, but scheduling them removes the ability to know what Activity was created so I can tie the Activity Data entries to it.

I’m not sure how to bundle up a bunch of keys and values via a Workflow to pass to a single API Workflow that would perform the task.

Love any ideas? Thanks!
Al

maybe two api workflows…trigger first from page and pass in all necessary values, then last step of the first api workflow is to trigger the second api workflow and pass in the values known from the first to tie that bow in the second api workflow

Hey @boston85719, thanks for the reply.

I could certainly model it that way. The thing I’m struggling with is HOW to pass that data into the first API Workflow.

Let’s say this is the data set:

=====
Activity
user: John Doe
page: Company
Activity: Company Name Updated

Activity Data
key: companyId, value: 12345abcd
key: dataBefore, value: Acme
key: dataAfter, value: ACME Corp

=====

The Activity data is easy because those are fixed data fields.
The Activity Data is tricky because these are any number of key-value pairs.

How can I pass this data to that first API Workflow, so that it can iterate and add the 3 Activity Data rows?

you have to format as JSON…there are different methods out there, some use plugins, others use bubble operators.

So I’ve managed to create the key-values JSON in a backend workflow (using JSON Toolkit), but am now stuck on how to create new Things out of this JSON.

Is there a plugin I’m missing that makes this relatively easy? Been banging my head against a wall for a couple hours and am kind of surprised this isn’t easier.

Appreciate any thoughts!
Al

This topic was automatically closed after 70 days. New replies are no longer allowed.