The equivalent of variables in API workflows

I’m being held back from doing any decent logic in API workflows, which I am using exclusively for my app. I have not found a way to do anything similar to variables. For example, in step 1, a “Do a search for…” action, then steps 2, 3, and 4 are all optional depending on the results of step 1, or utilizing the data of the search of step 1.

I found someone asking the same question, but the Toolbox plugin is completely broken for the Server Script. Otherwise, it would be a perfect (albeit a little clunky) fix. Variables (custom state) in API workflows

That was the only thread I could find on the subject. Anyone have any other solutions for variables in API workflows?

If your step 1 returns data with a “Do a search for” then the next steps can use the result of step 1.

You can add a “Make a changes to a thing” action as your first step. You don’t have to change any fields of this action. But this will ensure that you have the result to use in steps after.

I can’t figure out a way to do that though. As an example to start, I’m trying to use the Google Maps API to get the distance between two addresses in mileage. I’ve used it a ton outside of workflow APIs. Then, I want to take the mileage, and I have an additional 10+ actions after finding the mileage that perform calculations based on that first calculation. The only way I can find to do it now is to run that Google Maps calculation every single time that data is needed. Multiply that by other data I’m trying to use the same way, it becomes impossibly unwieldy and unreadable in a big workflow and is also dangerously inefficient with the various API’s I’m hitting.

I misspoke when I mentioned the “Do a search for”, I see how that would work but I realize that’s not where my bottleneck is.

1 Like

A workaround will be to save the result of the Google Maps API calculation to a database object.
And since you’ll be using a “Make a changes to a thing” action you will be able to access the result of this action, which will have the stored value in all the next steps.

1 Like