Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Iterative Macro with Dynamic Input

MD2050
8 - Asteroid

Hello Everyone-

We are working on building a workflow which will make an API to a web interface to pull required set of data. Since the data is spread over multiple pages we came up with an Iterative Macro solution which will loop in until all the data is pulled .

Issue is we pass dynamic date values in the Formula Tool after the initial Input Tool shown in the snippet below so in order to iterate to the next page the link which we get at the end of Output Loop "O" should feed to the Download tool instead of looping back to the Input Tool as it will get modified again in Formula tool which will defeat the purpose. Question is how to feed the link from the Output Tool "O" directly to Dynamic tool in order to iterate through the rest of the logic, is it possible ?

Also, Is the overall approach we adopted is correct given that we have to pull data based on dynamic date conditions over multiple pages ?

 

below text is passed in the Formula Tool (abc123 and abc456 are date start and date end parameters) 

"https://xyz.com?abc123="+datetimeformat(DateTimeAdd(DateTimeToday(),-14,'days'),'%m/%d/%Y %I:%M %p')+"&abc456="+datetimeformat(DateTimeNow(),'%m/%d/%Y %I:%M %p')

 

macroques.PNG

 

Thank You,

MD

4 REPLIES 4
seven
12 - Quasar

Hi @MD2050 

 

it is a little tough to troubleshoot this with just an image and no attached wf.

 

Since the initial string requires the Formula tool to pass a dynamic date value, could you feed this macro with an initial string first and remove the formula tool? Next, right before the macro out that loops back, add that Formula tool so the looped value has the next dynamic date and is fed back into the loop in macro input?

 

In other words, do not do dynamic dates first, do them last. The first value of the loop should have a dynamic date coming from the workflow that runs this loop. At the end of the first loop, a new dynamic date should be fixed to this API call and looped back in for the second run, and so on.

seven
12 - Quasar

Hi @MD2050 

 

I have enclosed a mock up of your workflow to illustrate what I mean by moving the Formula and logic.

seven_0-1594210130682.png

 

MD2050
8 - Asteroid

Thank you very much @seven -

We was able to revise the logic as per your recommendation and moved the formula tool outside the macro. 

The dynamic dates are passed only once at the beginning of the code in the formula tool and once it GET's the data from first page there is pagination cursor at the end of 1st page which points to the next page we needed to pass that pagination cursor link to the Input Tool and loop that logic in order to pull all the data from all subsequent pages. 

Just to confirm that in the configuration settings of Input Tool we pass the "Text Input" as a test template which basically changes dynamically based on the new link which gets passed from the Output Tool after the end of every iteration ?

After processing the new logic we are now getting an error shown in 2nd snippet below , which i am assuming is related to the web interface from where we are trying to fetch the data - is that correct?

Apologies for not sharing the WF because of confidentiality reasons.  

 

ques2.PNG

 

 

 

paging error.PNG

 

Thank you very much again.

 

 

seven
12 - Quasar

Hi @MD2050 ,

 

the formula tool outside the macro is there just to seed the initial value of the API. At the end of the first loop using this initial seed, the formula tool preceeding the macro out (the loop out) will use your dynamic date logic to prep the API call for the next loop, ad infinitum until the loops are done. The configuration settings of the macro in should have a valid API that works so you can effectively develop and test here. When you run it, the pagination for the second call should be done in that last formula tool and it should look like a valid API call. Then, you'll know that the loop will work over and over. You can move on to testing this macro by calling it from your main workflow and the data you feed in should be a valid API call, the loop will take over from there. I am not sure what that error is about, I can only surmise that it is related to invalid API strings at the beginning or end.

Labels