Passing a Javascript array as a list into an API Workflow

I’ve written a plugin that builds an array of URLs based on input provided to the plugin, whose last lines of code are:

instance.publishState(“array_of_urls”, urlArray)
instance.triggerEvent(“array_of_urls_is_returned”)

The purpose of the plugin is to allow users to upload and import a CSV file without having to re-edit it. They create a CSV file, they upload it, they identify which CSV file column heading identifies the URL, then they select Import.

Within the plugin, the Exposed state “array_of_urls” is identified as a text list.

Within the workflow where the plugin is used, I then write the array/list to the console.log using the plugin “Write to console”. It looks good.

As you can see, this plugin then triggers a new Workflow Event.

So, as the first action in that workflow event, I write the array/list to the console.log using the plugin “Write to console”. It looks the same. Still good.

The next action in that workflow is “Schedule an API Workflow on a list”.

To create the action “Schedule an API Workflow on a list” I have to specify “Type of things”, and “List to run on”.

And that is where I run into this obstacle.

I can’t find a combination of “Types of things”, and “List to run on” that work together.

The goal is to create DB records, one per URL, in a thing named “UrlProcessingQueue”, so I put that in “Types of things”.

The “List to run on” is, of course, the text list containing the URLs, but I’m not able to enter it. When I enter “The CSVImport’s array of URLs”, that is not a complete expression. I’m required to provide more, but none of the selections I can provide at this point make sense.

The message I’m seeing is: “Schedule API Workflow on a list: List to run on should be List of UrlProcessingQueries but right now it is a List of texts”.

Has anyone figured out how to pass a Javascript array to an API Workflow as a list?

What type of thing do you choose? you need to select “text” and provide the “list of text” from the state.

THANK YOU!!!

The answer was hiding in plain sight.

1 Like

I have a new question now.

I specified “Type of things” to be “text” and provided the a list of text to run on.

I’ve created two fields in the DB (for now) which are User and URL.

I’m not sure how to specify “This URL” except by using the “This text” option, which makes sense since I stated the type of things is text.

However, I am being required to say more, and I’m not sure what more to say.

Never mind.

This was pilot error I was able to figure out on my own.

Where I had created the Workflow API endpoing, I had checked a box for “is a list/array” because I thought I was being asked if the list was a list, which is hindsight does seem silly.

So what was happening was every DB record created contained every URL.

The fix was to uncheck that box, so that the URL parameter was defined as text, rather than a text list.

Thank you for your help earlier.

It was invaluable.

1 Like