SharePoint Designer 2013 workflow to propercase strings

Learn how you can make a string start with a capital letter in a SharePoint Designer 2013 workflow.

ADVERTISEMENTS

Problem

SharePoint Designer workflows do not offer an uppercase function you can use to convert the first letter of a string into a capital letter, but you still want to be able to propercase a string via a workflow.

Solution

You can use SharePoint workflow variables and the String Builder dialog box in SharePoint Designer 2013 to be able to propercase a string in a workflow.

Note that you can extend the technique shown below with a workflow loop to create a solution with which you can convert a string to uppercase or lowercase in a workflow.

In this example, you are going to propercase the string that is stored in a field of a SharePoint list item.

To perform string propercasing in a SharePoint Designer 2013 workflow:

  1. In SharePoint 2013, create a new SharePoint list named MyList that has one column named Title.
  2. In SharePoint Designer 2013, create a new List Workflow that runs on the MyList SharePoint list. Name the workflow ProperCaseStringWF and leave SharePoint 2013 Workflow selected as the Platform Type.
  3. Create a local variable of type String named upperalphabet.
  4. Add a Set Workflow Variable action to the SharePoint workflow, and configure it to say:

    Set Variable: upperalphabet to ABCDEFGHIJKLMNOPQRSTUVWXYZ
  5. Create a local variable of type String named loweralphabet.
  6. Add a Set Workflow Variable action to the SharePoint workflow, and configure it to say:

    then Set Variable: loweralphabet to abcdefghijklmnopqrstuvwxyz
  7. Add an Extract Substring from Start of String action to the SharePoint workflow, and configure it to say:

    then Copy 1 characters from start of Current Item:Title (Output to Variable: substring )
  8. Add a Find Substring in String action to the SharePoint workflow, and configure it to say:

    then Find Variable: substring in Variable: loweralphabet (Output to Variable: index )
  9. Add an If-condition to the workflow that says:

    If Variable: index not equals -1
  10. Within the If-condition block, add an Extract Substring of String from Index with Length action to the SharePoint workflow, and configure it to say:

    Copy from Variable: upperalphabet, starting at Variable: index for 1 characters (Output to Variable: substring1 )
  11. Within the If-condition block, add an Extract Substring from Index of String action to the SharePoint workflow, and configure it to say:

    then Copy from Current Item:Title , starting at 1 (Output to Variable: substring2 )
  12. Create a local variable of type String named propercased.
  13. Within the If-condition block, add a Set Workflow Variable action to the SharePoint workflow, and configure it to say:

    then Set Variable: propercased to [%Variable: substring1%][%Variable: s...
    where you must use the String Builder dialog box to construct a string that makes use of the substring1 and substring2 workflow variables and that says:

    [%Variable: substring1%][%Variable: substring2%]
  14. Within the If-condition block, add an Update List Item action to the SharePoint workflow, and configure it to say:

    then Update item in Current Item
    where you must set the value of the Title field to be equal to the value of the propercased workflow variable.
  15. End the SharePoint workflow with a Go to a stage action.
  16. Configure the SharePoint workflow to start automatically when an item is created.
  17. Publish the workflow to SharePoint 2013.

In SharePoint 2013, navigate to the MyList SharePoint list and add a new item that has its Title field set to for example this is just a test. Once the workflow has run and completed, the text This is just a test should appear in the Title field of the SharePoint list item.

Related Articles

ADVERTISEMENTS