API Connector | Using Dynamic URL Parameter | Collecting and saving data

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:

  1. call all the documents for that specific period and save in a temporary DB;
  2. 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.

Here is the documentation (see get documents and get documents by ID)
https://pos.cloudware.pt/ws/v1.1/#tag/Documents/paths/~1documents~1%7Bid%7D/get

API Call format:
Get document:
https://pos.cloudware.pt/ws/v1.1/documents?api_key=xxxxxxxxxxxxxxxx
Get Document by Id:
https://pos.cloudware.pt/ws/v1.1/documents/[id]?api_key=xxxxxxxxxxxxxxxx

I hope someone can help me step by step :pray:

Thank you

Backend workflow 1

  1. Call all documents for period
  2. Schedule BEWF 2 on the resulting list of document IDs
  3. Schedule BEWF 1 to run again next day

Backend Workflow 2

  1. Call all items based on received doc ID
  2. Schedule BEWF 3 on the resulting list of items.

Backend Workflow 3

  1. 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.

Hope this helps get you going!

Cheers,
Gaby
Coaching No Code Apps

1 Like

Hi @romanmg , thank you so much for your tips!
I’ll try and give some feedback later!
Thank you!

1 Like

Hi Gabby,

First of all, thank you for your help.

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.

I will share step by step what I did:

First, I created two new data types:

  • Documents (Main fields: MySoftware_Doc_Id, Gross Amount, Client Name, Date…)
  • 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?

Thank you,

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?

Hey Gabby,

After long hours makins some trials and paying extra WU I think I found out!

I just need some adjustments but I’m happy I’ve won a new skill! :joy:

Thank you very much for your help. If I have time I can post the final solution in the end.

Cheers,
Edd

1 Like

Awesome!! Nice work, Edd :slight_smile: