Switch function walkthrough
For simple data changes, use the Switch function to transform one value to another within a module field. In this exercise, change the two-letter key to the actual name for project Progress Status sent in an email.
Switch function walkthrough
Workfront recommends watching the exercise walkthrough video before trying to recreate the exercise in your own environment.
The purpose of this next walkthrough exercise, is to learn how to change a two letter key output for progress status on a project, into something more recognizable, the word “Late.” We’ll clone our scenario for sharing variables between routing paths, and we’ll add the progress status to our email module, and use the switch function to change those two letter key values into something more recognizable. To be successful for this walkthrough exercise, you want to find our sharing variables between routing paths walkthrough exercise, have your test drive available as well, and have your own email account also available.
Let’s start by cloning our previous walkthrough exercise, titled “Sharing variables between routing paths.” We’ll name the new scenario, “Sharing variables between routing paths - switch.” To make the progress status on each project available, I need to left click in my find current project’s trigger module, and use command G to find it in the output list.
Go ahead and select it, and then click okay to save.
Once I do that, I can now click in my email module and I can use HTML tags, to separate these lines.
And then I’ll add progress status at the bottom.
Let’s go ahead and grab progress status from the mapping panel.
Then we’ll click okay.
We’ll save.
And we’ll run once.
Once it successfully runs, we can go to our email account and evaluate the email sent there. We can see everything looks good for the project name, description, and sponsor, that for progress status, we’re getting a two letter key for the progress status, instead of the word that the key refers to. We want to see the word late in this case, not the key LT. To change the two letter key into a recognizable value, we need to use the switch function, which we’ll do in the next video.
Let’s go back into our email module, and change the two letter key for progress status, into a recognizable output. Let’s start by removing our progress status item, put a space in there now. And then we’re going to go to our mapping panel. In the general functions tab, we’ll choose switch.
For the first space in the switch function, we’ll add back the progress status.
Or the expression we want to evaluate. After the semicolon, we’ll say that if the return value is LT, then we want to have the output be “Late.” We can add another semicolon, simply by typing it, and then say if it’s OT, the output is on time, and then we can continue for at risk and behind.
If this seems a little messy to you or it’s hard to read, to make sure that you’ve set it up correctly, up at the top here of the module panel, there is an expanded option, which does allow you to have a little more space to see it more clearly. Once you set up your switch function, click okay to save your work, and we’ll click save to save our scenario, and then we’ll run once again.
Once it successfully runs, let’s go ahead and check out our email that we received.
We can see that instead of getting a two letter key for the progress status, we have now changed it to late.
If this project was on time, or behind or at risk, it would make the same switch as well, and return a recognizable value for whoever is receiving this on the other end. -
Want to learn more? We recommend the following:
Workfront Fusion documentation