Page 1 of 1
Change my variable ?
Posted: Wed Nov 23, 2016 3:42 pm
by numnational
Hi all,
I want to change my variable in switch.
Example :
i have un pdf file with the name "JMIKxxxxx.pdf" i want to depose it with "Set Hierarchy Path" in "JDM" folder.
i have un pdf file with the name "MICPxxxxx.pdf" i want to depose it with "Set Hierarchy Path" in "MPG" folder.
and other and other...
Is it possible to changing the variable ? I want to attribuate "JMIK" = "JDM", etc...
I can make it with a rename tools but if a better solution exist it's better.
Thanks.
Re: Change my variable ?
Posted: Wed Nov 23, 2016 3:54 pm
by gabrielp
If you have Scripting, you can use
switch-private-data-write to write and modify variables with private data. If you don't have Scripter, you can use can use
metaTagger in the appstore to do the same thing. Otherwise, you can use JobState to set a single variable within a folder, but I wouldn't recommend this.
Once you write your variable in your flow (lets say it's private data with the key "Code"), you can put that in your Set Hierarchy path with the "define single line text variables" option. You would enter in something like: [Job.PrivateData:Key="Code"].
Re: Change my variable ?
Posted: Wed Nov 23, 2016 4:09 pm
by numnational
Thanks Gabriel,
I have scripting so i want to test switch private data, but i don't understand how i must install it to work with switch... can you show me a tutorial to install and use it ?
Thanks.
Re: Change my variable ?
Posted: Wed Nov 23, 2016 5:12 pm
by gabrielp
Sure.
- Download it using the "clone or download button".
- Put the files somewhere.
- Drop in the Script configurator within Switch and load the private-data-write_25.sscript file.
- Set Key (the first one) to Code
- Set -> Value to JDM
- Duplicate the script
- Alter the -> Value of the duplicated script to MPG
- Now you have two of these private data scripts, one writing Code to JDM and the other writing Code to MPG.
- Set your hierarchy value to [Job.PrivateData:Key="Code"] by using "single line text with variables"
- Now jobs routed through the JDM pd script will resolve to the JDM hierarchy
---- Jobs routed through the MPG pd script will resolve to MPG hierarchy
If you can post your flow, I can alter it for you to build a working example. Otherwise, if you want to jump on Gitter, I can spend a few minutes with you to walk through it over a webinar.
Re: Change my variable ?
Posted: Thu Nov 24, 2016 11:08 am
by numnational
Thanks a lot your explications are very clear.
I make your lessons, and you can find my flow here :
https://www.dropbox.com/s/4e3q2wk1zi852 ... sflow?dl=0
It work perfectly. But...
As you see in my flow I have another solution in bottom of the flow with "attach job state". It work perfectly too. What do you think ? What is the best solution ?
Thanks.
Re: Change my variable ?
Posted: Mon Nov 28, 2016 5:05 pm
by gabrielp
Excellent work.

This is very good. But if you follow
switch-best-practices, you can make it a bit more readible and easier to debug:
One good thing to keep in mind is to make folders named something unique so when they fail, you can figure out exactly where they failed from.
numnational wrote:
As you see in my flow I have another solution in bottom of the flow with "attach job state". It work perfectly too. What do you think ? What is the best solution ?
That's correct. You can do this with JobState, but I really don't recommend it. Using JobState is confusing because it is unclear what JobState actually is at any point in time. In this example, it's so simple so it doesn't get confusing. But as you make larger flows, or flows that pass jobs into other flows, at any point in time you'll not know what JobState is actually set to. Perhaps you set it to a CSR's email or a job quantity. With private data, you always know what the data is supposed to be. And of course the biggest limitation is that you can only write one variable at a time.