One of the SharePoint Designer workflow activities I use most in SharePoint 2007 is Build Dynamic String. It is a very convenient way to create a customized string of dynamic text that I can then use and re-use for email subject lines, descriptions, task titles, and all sorts of things.
Unfortunately, Microsoft made the decision to disable the Build Dynamic String workflow activity in SharePoint 2010. You may have already discovered Greg Osimowicz’s blog post about how to re-enable the Build Dynamic String activity in SharePoint 2010. However, not only is this method neither recommended or supported by Microsoft, but if you aren’t the SharePoint Server administrator, you probably can’t edit the WSS.Actions file anyway. So, how can YOU, as a workflow designer, Build a Dynamic String in a workflow in SharePoint Designer 2010?
In SharePoint 2010, Microsoft has replaced the Build Dynamic String activity with four new Utility Actions to Extract Substrings. While all of them are useful, only one of them properly replicates the Build Dynamic String activity from SharePoint 2007: Extract Substring from Index of String. In this post I’ll explain how to use this and then explain why the other three don’t properly duplicate the Build Dynamic String function.
How to Use Extract Substring from Index of String Workflow Activity
When you add the Extract Substring from Index of String activity to your workflow, it will look like this:
You’ll notice that there are three parameters you can edit: the original string, the starting character, and a variable to store the result. If you change the starting character from 0 to 1, this activity will work exactly like the Build Dynamic String activity did in SharePoint Designer 2007. Here, you can see how the parameters line up:
When you click on string, you will have the option of clicking on an ellipses button […] to Display builder for this parameter, or the [fx] button to Define workflow lookup. If you click on the ellipses, you will see the String Builder window just like you were used to in SharePoint 2007. Use this window to build your dynamic string as you want it. Then change the Output Variable to a variable of your choosing. That’s all there is to it! This
Something to Be Aware of – In order for this to work, you must change the starting at value to 1. If you leave it at 0, you will end up with an empty string. If you use a value greater than 1 your final string will be missing characters at the beginning.
Why the Other Three Extract Substring Activities Won’t Replicate Build Dynamic String
The other three Utility Actions are: Extract Substring from End of String, Extract Substring from Start of String, and Extract Substring of String from Index with Length. You can see these three activities and their parameters in the screenshot here (in the order I listed them):
You’ll notice that each one has a variable for the number of characters. If you leave this at 0, your variable will contain an empty string. Also, if you enter a number that is greater than the length of your string, it will contain an empty string! So, these activities are only useful if you know the exact length your output string needs to be; this is very unlikely if you are building a dynamic string (it is dynamic, remember). These actions will only return a value if the number of characters parameter is less than or equal to the length of the string parameter.
So, there you have it. I hope you find this useful.