I am trying to build a batch macro where I can mask multiple string fields in one batch macro.
If as an example my input data looks like:
I want to get to a position when the Company and SalesPerson string fields are masked to be as follows (with the field name becoming the prefix).
I've built my macro, but the output I get is like this:
So the macro seems to be running through twice and unioning the results, but what I want it to actually do is iterate over the input and take the input after the first pass through (i.e. "Company" being passed to the control parameter) to become the input for the second pass through (when "SalesPerson" is passed to the control parameter).
I can get it to work by putting the same macro in twice and passing to the 1st control parameter "Company" and the second macro "SalesPerson", but for the real dataset I'm trying to do this to, it has many fields and so I've just put two in to explain the issue. I feel like I'm close and it might be just a configuration setting that needs adjusting, so any help appreciated.
Solved! Go to Solution.
Hi,
Your macro didn't seem to come attached to this process.
However, I'm curious if we can't come up with a solution that doesn't require a macro.
I attached a workflow which I think accomplishes what you are looking for without a macro, and also includes some randomization of element order so that company/salesperson's get different ID's each execution.
Let me know if this helps!
Like @Claje - think this is best done without a batch macro.
For each field create a masked value for every unique value and then put back in place of the original with a join
[Duplicate]
Awesome both! I'd been racking my brains for over an hour trying to solve and the community comes back with two solutions in almost as many minutes!
I think I was going down the macro route as I want it to be a tool to just drop in to any workflow, but seems like that's caused me to end up in the rabbit hole!
Is there a more dynamic way of updating the order in the last join to match the column order of the input. I'm just thinking when the number of fields to mask get large getting the right order will be a pain?
@Claje challenge me on the same thing.
This package has a dynamic join in the middle of it. It basically matches fields by name and replaces. It does this using an internal batch macro and configuring it by a wrapper macro.
The result is the fields to be masked are selected in the transpose and just flows through
Thanks James for this. I really liked the approach to changing the XML.
Having shown your solution of the macro to ensure the column order remains after anonymising to a colleague (@nikolaskardsis), we've come up with this solution which doesn't require dynamically changing the XML.
Proposed alternative solution:
By putting the masked part of the workflow as the left input to the join, and the original data as the right input, then deselecting duplicate fields and record ID (this will keep the new masked fields and remove the original ones), then by unioning the data with the original headers results in reordering the fields back to the original order.