Hi everybody, need some help:
I have an API Call to ask my invoice software a document information by its ID (in this case is an Invoice information). That document, has a sub-call composed by all the items that this invoice has.
My final goal is to “catch” all the items sold in a specific period (lets say the entire day) and save it in a bubble DB. Unfortanbly this API/software doesn’t have a DB with the Items sold. They are appended to an API Call Document by ID.
I know that the way to do it is somehow like this:
call all the documents for that specific period and save in a temporary DB;
Making a 2nd call to ask the items list for each document id from the first call, collecting it and saving it a DB
I already have created the API call’s, however I have no clue how to create the workflow to accomplish the two steps.
In the perfect situation I would have this working in a backend workflow running everyday at mid-night, for example.
Schedule BEWF 2 on the resulting list of document IDs
Schedule BEWF 1 to run again next day
Backend Workflow 2
Call all items based on received doc ID
Schedule BEWF 3 on the resulting list of items.
Backend Workflow 3
Create DB record to save item details
Notes
Something needs to trigger BEWF 1 to run for the first time. Add a button somewhere to schedule it once with whatever parameters it needs initially. From there, it’ll run recursively.
Pay attention to your recursive logic/timing so you don’t end up with a runaway workflow and end up creating thousands of records by accident. Use your infinitive recursion protection settings (Settings > API)
BEWF 2 should receive, at minimum, the doc ID as a text parameter
BEWF 3 can happen a couple ways. Either you set up a parameter for every individual item value. Or, you could just receive the item ID and within this workflow, run a 3rd API call to get the individual item. The latter is a bit redundant since you’re already getting all that info in BEWF 2 and just need to parse it out, but if you’re looking to save dozens of values, then a 3rd API call might be easier to work with. Just consider the extra WU cost to run another API call at scale.
EDIT: Oh, also, I suggest you build it first without the recursive action (the action that schedules BEWF 1 to run again). This way you can test the full flow 1 run at a time on its own safely. Once you can confirm that everything you want is created in the DB, then you can add the recursive action.
In general, your advice is working, although I am encountering an issue with a recursive action. I was confident that this wouldn’t happen, but I’m not sure why it’s happening yet.
Documents_ProductsItems (Product_ID, Qty, Gross Amount, Net Amount, Doc_ID, Date…)
Regarding the workflows, I created two different ones:
Button A – Run WF1 (index=1)
WF1 - Replicate my invoice software Documents:
Step 1: Create a “Documents” data type entry using the “Get Documents_List API” (filtered by date = today - 1) with the main information. Step 2: Run WF2 (index = 1, doc_id = Step 1 “MySoftware_Doc_Id” field) item index. Step 3: Add the result from Step 2 to the Items variable (perform a Do a Search). Step 4: Run WF1 again with index = index + 1 until index < Count of documents created from the day before. Step 5: Run WF1 again with index = 1, schedule date = today + 1 day (rounded down to the day) + 10 minutes (to schedule for 00:10:00 of the next day).
WF2 - Replicate and save the items in the DB:
Step 1: Create index ProductsItems through the Get Documents by ID. Step 2: Repeat only when INDEX < items:count.
I just need to solve the issue of the infinite recursive action I created, which I had to stop in the settings under the Workload Usage Menu.
One question: How can I cancel a workflow through the app, especially in a situation like this where I have workflows within workflows with recursive actions?
Hey! Ok, I might need to see screenshots of your recursive steps because it seems like you’re using an index system rather than scheduling “on a list.” An index system is fine too, and I think you’re on the right track with 3 recursive flows:
One for the daily run
One for creating each doc
One for creating each doc item within each doc
But I’m not sure I’m following your adjustments. The issue may be in the conditional logic. Do you know which of your 3 recursive actions is happening infinitely?