Hi SME,
I have a complicated workflow that has an user workflow constant (Year) permeated throughout. I have to update this constant for multiple times for each run. For example, if I have to run the workflow for 5 years, I would have to update the constant five times for each run.
I have built an iterative macro to give me a dynamic input for a list of years, but I'm unclear on how to use it to change the user workflow constant so that I don't have to do it manually one at a time for multiple years.
Could you please provide some insights on how I can approach this problem?
Thanks,
kwl
@geraldo - The workflow runs on a desktop. We thought about creating an app to get the parameters pass through; however, we don't want to hook up at each node where the parameters occur - way too many. That's why we want to update the user workflow constant. One way I thought of doing this is to leave the user workflow constant alone and create a batch macro that takes a list of years and months to run through workflow to append the results. I'm re-learning the Batch Macro again as I keep forgetting how to use it. Thank you much!
I thought I didn't want to turn the first stream into a batch macro. This makes changing parameters very simple.
good luck
Thank you @geraldo
@geraldo - Since I have two values to send to the Batch Macro - Year (From/To) and Month (Current - otherwise 12 months) - do I have to create two columns for the Year and incorporate the month into a formula? In other words, for the Year, do I have to create one called Name and the other value - both of which just pick up the year such as Year1 = 2015 and Year2 = 2016? In other words, can I leave it as one column with the year and feed it into the Batch Macro?
@geraldo - Is there a way that I can use the Formula tool to update the user workflow constant? I can update a current field or create a new one to pick up the user workflow constant, but it's unclear how I can set up the user workflow constant to pick up a designated value. I kept going in circle, but at the end, I still need to update the user workflow constant. For example, if I have the user workflow constant set at 2023 for Year, I would need to somehow update User.Year with the input value from the Numeric Up Down tool. Right now, I can only set the [Year] = ToNumber("%User.Year%") but not the other way around.
You cannot update the value of a User Constant.
I only use User Constants when I'm certain the values will be relatively static, like OutputFolder or OutputFileName, never for something like a Year or Date parameter.
You need a Global Value that you can update easily, and use easily in many places. That's not something you can do in one place, without getting the updated value from a Formula tool or a batch macro input parameter, and "touching" each place you need to use that value. (touching with a tool like an Append)
One option would be to review the actual XML of your main workflow... open the YXMD file in Notepad or Notepad++ and find the section for <Constants>
Create a new workflow that reads in your main workflow as a CSV file, no Delimiters, no field names on first row.
Then use Alteryx tools to update the XML for the main workflow: change the Constant value found in a line like this: <Value>XYZ</Value>
Then save the updated XML file.
Then call the main workflow using one of the CReW Runner macros. Or try Chained Apps.
This is a risky approach, so make sure you have backups.
Long term, suggest you re-design your main workflow to not use User Constants for things like Date or Year parameters, if you want to automate updating those values.
XML file:
Read in YXMD file as a CSV file, no Delimiter
Chris
you didn't show the structure of your workflows;
First to update any tool in alteryx it has to be macro.
if you have constants in macros you already built it wrong.
As I told you in the other post, the problem is in your first workflow, you said that you can't read anything externally or receive external parameters.
In the macro you can replace a constant '%Year%' in a formula tool for example.
Again your problem is in the first workflow because it is the one that says the rule if you set it constant every time you will have to edit it change what you want to save upload to the server or send a version to the automation schedule.
@geraldo - I couldn't agree with you more. I wouldn't have built the workflow the way it was built. Unfortunately, it was out of my hands, and it's way too complicated to fix the workflow or have the many touching points with a macro - and I don't have the liberty to do so. I believe this workflow was built when the group was still in its infancy without any knowledge on using macros and analytic apps. In any case, here's what I'm trying to now with the attached workflow as an example. I'll work on an iterative macro to build out a table of current month/year and end year based on input. Then, using the table to feed into the batch macro by changing the user workflow constants. The batch macro will output the end results by grouping the year. I'll play around with the suggestions made @ChrisTX .
@ChrisTX - Thank you. Will give it a try.
@geraldo - What if I use the user workflow constants as a starting point meaning the user.year is the current year and user.month the current month? The user is responsible to update the user workflow constants manually. Then create a control parameter table to go from the current year/month to a specified year such as 2015/12. Feed this into the upside down question in the batch macro with the big workflow attached to the other anchor to run through the batch macro to get the appended outputs. I'm modifying the iterative macro you had helped me before to see if I can get this to work. Many thanks!
@geraldo - This is my attempt at creating an iterative macro for the control parameter table. I kept getting an error at generating the rows. Could you please help me take a look? Thanks!