Forum Academy Marketplace Showcase Pricing Features

How to mix two Lists in an API Workflow

Hello,

I’m facing an issue (might be a BUG) on :MERGE List. I also need your advices to find a better way solving this issue.

I have a data base of 1000 items named KD.

  • 900 KD are green (for example)
  • 100 KD are red (for example)

I want to show to the user a unique KD list with 10 KD green, 1 KD red, 10 KD green, 1 KD red, 10 KD green, 1 KD red , 10 KD green, 1 KD red , 10 KD green, 1 KD red etc …

To do this:

  • I create a User KD List field : “KD Green List”
  • I create a User KD List field : “KD Red List”
  • I create a User KD List field : “KD FINAL List”

Then I create 2 API Workflows which run in the background:

  • User_KD Green List = Do a Search KD which are Green
  • User_KD Red List = Do a Search KD which are Red

This works fine and the 2 lists arrive pretty fast :slight_smile:

But in the API Workflow I don’t know how to mix the two lists into one as described below (10 Green, 1 Red, 10 Green, 1 Red etc …). I cannot create incremental loop as there is no variable in API Workflow that are required for a loop.

So I have created a standard Workflow “When User Login

This workflow cherry pick from each list and build the KD-FINAL-LIST thanks to an incremental loop to select 10 KD green then 1 KD Red then 10 KD Green then 1 KD Red… etc…

  • CLEAR KD-FINAL-LIST
  • KD-FINAL-LIST Add KD Green List Item1: Until:10
  • KD-FINAL-LIST Add KD Red List Item1: Until:1
  • KD-FINAL-LIST Add KD Green List Item1: Until:10
  • KD-FINAL-LIST Add KD Red List Item1: Until:1

It works, but the Problem is it takes a lot of time to go through the whole process (20 to 30 seconds)…
How could I accelerate this and make the cheery pick process running in the background with an API Workflow?

Any idea or recommandation to do this in the background with a smart API Workflow?

WORKAROUND FAIL
I thought the latency might come from an extensive usage of the 3 User_KD-List fields (hard drive access) so I decided to try with 3 CUSTOM-STATES Lists.

But when I use the :MERGE function with CUSTOM-STATES-Lists into a loop it looks like the :MERGE re-initialize the CUSTOM-STATES list every loop … So I cannot :MERGE the CUSTOM-STATES lists in a loop. :frowning: Is that a bug ? (Believe me I have done a lot of tests…)

Now I have no more ideas and I’m blocked by this issue.
Thanks in advance for your support and ideas…

Best Regards
Pierre

1 Like

You can create incremental loop using endpoint and a workflow with +1 value, and check if the condition still what you want. Simple example here:

Hi John Mark,

Thanks for the answer, but while I vaguely understand your concept, I miss concrete example.

To be transparent, I’m a bit lost between API WORKFLOWS, Recurrent, Endpoint, Custom… And the workflows Schedule a API Workflow… etc…

One of my issue is that I need 6 parameters to do the incrementation. Where do you put these parameters as I haven’t found a way to create a Custom State in the API WORKFLOW.

Could you share a bit more about your solution as an example?

Thanks in advance for your support.
BR
Pierre

You save your value on the database directly, as the concept of ‘state’ on API Workflow don’t exist. API workflow have no user (or login) needed. It’s like a standalone machine that execute operations without been log in, but perfect to send jobs in the background, not affecting any real user operations.

In my example I used a field LINE that increment +1 each time it run inside the LOOP. I have another condition that check if LINE is 10, and Terminate the process (action) at the Endpoint, like:
34%20PM

More info here:

When using states on a page, it can be ‘dangerous’ if you make some process on a list, and decide to quit the page… all states are erased. Same if you change the states during a process for other values.

Hi John Mark,
Thanks for the explanations. Very useful.

Your field LINE is located where ? In the User DataBase? I understand you create LINE as a Parameter in the EndPoint and increment it.
But I haven’t found a way to write the increment (LINE + 1) in the Endpoint field as you show.
I cannot find the endpoint Parameter in the list…

As a workaround I’m using a field in current User data base… But I fear it slows the process.

Thanks anyway for your detailed explanations.
Best Regards
Pierre

The value is created at the EndPoint level (replacing the official term ‘state’ with ‘parameter definition’). Easy to forgot about it.

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