This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
The good news is, it works. The bad news is it's my first iterative macro so it's kind of hacky and trashy and I know I can refine it. Without getting too much into the use case I think I can just ask this question generically and get where I need.
I ask my user to add 2 inputs into the macro. One is the actual key value (which is what the workflow is designed to work with), I also ask the user to add a blank field. The blank field is where I except the iterative macro will place the iteration number. Because it suits what I'm trying to do, imagine that instead of using the engine variable for iteration number, I'm actually just doing field = field + 1 early in the workflow.
Anyway, I want to do that, but I don't want my user to have to add the blank field. I want it to be added at run time. But I want to preserve it's contents, so restarting it as empty won't really work. I also am under the impression that sending the field I want to preserve back through the iteration will either fail out "input has changed" or would result in just a bunch of fields added for that iteration. This is a pretty rudimentary example, I actually have several fields that I want to use to create kind of a chain throughout the macro.
I wanted to seek some wisdom from more experienced folks as to how to approach something like this. I've had a few ideas:
1) Find a way to conditionally add the field if missing, or add to the field if present.
2) Serialize my records on input create a temporary storage file that gets updated as part of the iteration process. This might require multiple outputs which I don't know if it's possible with a vanilla custom tool.
3) Try to build the output as a collection of concatenated fields, maybe create a second tool to deconstruct and layout the output as desired.
Here's one way you could do it. Since there isn't a way that I can think of, or find, to add a field to an iterative macro AND preserve its value across iterations, this solutions wraps the iterative macro in a batch macro who's purpose is to add the new output field before calling the iterative macro and then rename it to the name passed in the control parameter