Javascript cannot connect that triggers an API

I get the following message in a workflow (Did not add dependency because triggered blocks cannot have explicit connections.) and cannot connect a javascript that triggers an API.

Therefore, the workflow does not run completely through and skips the last two processes.

What could be the reason or what could I do to make it work?

As tooltip, there is not explicit connections between billbee_array and billbee_shipment_post.
you should drag the gray point at the right top of billbee_array to billbee_shipment_post, this will connect them in the same flow.

Hi @AnsonHwang , that's exactly the problem, I connect the two and then I get the message like in the screenshot. They won't connect.

Maybe it's because I'm triggering the API in the JavaScript?

        try {
            const response = await billbee_shipment_post.trigger({
                additionalScope: {
                    orderId: BillBeeOrderId[i],
                    ShippingProviderId: shippingProviderId,
                    ShippingProviderProductId: shippingProviderProductId,
                    ShippingId: TrackingNo[i]
                }
            });

As far as I understand it now, you can't connect any javascript that triggers an API. But how do I get this solved then? Because the trigger does not trigger the next step.

Maybe @Tess can help? :upside_down_face:

The workflows run in a row as you connected. In the pre step you should no trigger the next step.

I think you should change the position of this two block.
in js you can write billbee_shipment_post.value to retrive its value.

I can find absolutely no way to make this work. My biggest problem with the code was that I have to run the api asynchronously through a loop. Is it possible that something like this doesn't work in the workflows at all?

I have a SQL query that looks like this:

SELECT BillBeeOrderId, ShippingProvider, TrackingNo
FROM billbee_order
WHERE ShippingDataTransferredAt IS NULL AND TrackingNo IS NOT NULL

example result:

{"data":[{"BillBeeOrderId":1234,"ShippingProvider":"DPD","TrackingNo":"1234"}],"metadata":null}

i run the results trhoug the javascript:

const orders = db_abfrage_pending_shipments.data;
const { BillBeeOrderId, ShippingProvider, TrackingNo } = orders;

async function processOrders() {
    for(let i = 0; i < BillBeeOrderId.length; i++) {
        console.log("Aktuelle Bestellung:", BillBeeOrderId[i]); // Debugging-Statement      

        const shippingProviderId = 
            ShippingProvider[i] === 'DPD' ? '22009' :
            (ShippingProvider[i] === 'DHL' || ShippingProvider[i] === 'DHL Freight') ? '22005' :
            ShippingProvider[i] === 'TNT' ? '22429' :
            ShippingProvider[i] === 'Emons' ? '22007' :
            ShippingProvider[i] === 'GLS' ? '22006' :
            '22426';

        const shippingProviderProductId = 
            ShippingProvider[i] === 'DPD' ? '286842' :
            (ShippingProvider[i] === 'DHL' || ShippingProvider[i] === 'DHL Freight') ? '286841' :
            ShippingProvider[i] === 'TNT' ? '291023' :
            ShippingProvider[i] === 'Emons' ? '286843' :
            ShippingProvider[i] === 'GLS' ? '286844' :
            '291008';

      
        try {
            const response = await billbee_shipment_post.value({
                additionalScope: {
                    orderId: BillBeeOrderId[i],
                    ShippingProviderId: shippingProviderId,
                    ShippingProviderProductId: shippingProviderProductId,
                    ShippingId: TrackingNo[i]
                }
            });

            console.log(`Response für die Bestellung ${BillBeeOrderId[i]}:`, response);
        } catch (error) {
            console.error(`Fehler bei der Verarbeitung der Bestellung ${BillBeeOrderId[i]}: ${error}`);
        }
    }
}

processOrders();

return(processOrders())

and this script actually triggers the api with every dataset. normally in my app this runs without problem, but not in the workflows

If you are using the API node why are you calling the node in the JavaScript? If it is for a loop to go through each set of data, you probably want to make a loop node using the code block. The loop would process all of the rows from the block and send the payloads to the Billbee API resource.

To be clear, the code block is getting all of the data ready, and the API resource is sending all of the data as a single payload each time, correct?

If so, the workflow design would be (trigger)-->(code)-->(loop with "code" as loop input and API resource as the action)

I have a couple of workflows that loop from an array built in a code block so I'm fairly certain the explicitness being thrown as an error is your self-reference to the query node in you code block.

Would you have an example code for me?

I used this data as a start and just added in the ShippingProviderProductId for clarity:

I don't know the specifics of your API calls, but the loop block I'm using what looks like the individual payload data by row; the loop executes for each row using the additionalScope structure you provided.

The {{value.property}} syntax is what you'd use for URL params/JSON body/URL Form Encoded payloads.

1 Like

Just before you wrote, I had the solution. I have only now seen that you can create a loop as a block and enter all the data of the API etc. there. :see_no_evil:

thank you

1 Like

I ran into this same error message. I realized I couldn't do what I was trying to do so I deleted my Javascript block and tried to reconnect my SQL block back the way things had been. And I got this error. I tried deploying. I tried making silly changes to trigger some sort of rethink. Nothing worked until I created a fresh SQL query, copied the settings from the old one. Then I was able to reattach things and delete the old query block.

So there are three problems:

  1. When everything is working correctly this is confusing.
  2. That the error message appears at the top of the screen for about 2 seconds is NOT helpful!
  3. The IDE state gets corrupted and this error is triggered when the error state, in fact, no longer exists. That is a big problem.

Hey @Roland_Alden!

Thanks for this feedback, I'll pass it along to the team. There's an open request for better debugging features in the Workflow editor that I can report back here on. I can certainly imagine how it would be helpful to have error messages be more accessible and it's important that they be consistent.

Glad yall were able to figure this out for the rest and thank you for sharing your solutions here!