SharePoint Designer 2013 workflow to concatenate strings

Learn how you can use the String Builder in SharePoint Designer 2013 to concatenate two or more strings with each other.

ADVERTISEMENTS

Problem

SharePoint Designer workflows do not offer a concat function you can use to concatenate two or more strings with each other within a workflow, but you want to still be able to concatenate two or more strings with each other.

Solution

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

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

To perform string concatenation 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 ConcatenateStringsWF and leave SharePoint 2013 Workflow selected as the Platform Type.
  3. Create a local variable of type String named TextString1.
  4. Add a Set Workflow Variable action to the SharePoint workflow, and configure it to say:

    Set Variable: TextString1 to 1
  5. Add a Log to History List action to the SharePoint workflow.
  6. Click message in the sentence for the workflow action, and then click the ellipsis (...) button behind the text box that appears.
  7. On the String Builder dialog box, click Add or Change Lookup.
  8. On the Lookup for String dialog box, leave Current Item selected in the Data source drop-down list box, select Title from the Field from source drop-down list box, and click OK.
  9. On the String Builder dialog box, type an underscore ( _ ) immediately after the text that is present in the Name text box, and then click Add or Change Lookup.
  10. On the Lookup for String dialog box, select Workflow Variables and Parameters from the Data source drop-down list box, select Variable: TextString1 from the Field from source drop-down list box, leave As String selected in the Return field as drop-down list box, and click OK. The final expression in the Name text box on the String Builder dialog box should now say:

    [%Current Item:Title%]_[%Variable: TextString1%]
  11. On the String Builder dialog box, click OK.
  12. End the SharePoint workflow with a Go to a stage action.
  13. Configure the SharePoint workflow to start automatically when an item is created.
  14. Publish the workflow to SharePoint 2013.

In SharePoint 2013, navigate to the MyList SharePoint list and add a new item. Once the workflow has run and completed, navigate to the workflow history list, and verify that a _1 was appended to whatever text string you entered into the Title field of the SharePoint list item.

Discussion

In the solution described above, you learned how to use the String Builder dialog box in SharePoint Designer 2013 to concatenate the string stored in a variable to a string stored in a field of a SharePoint list item.

You can use the String Builder dialog box this way to concatenate any amount of strings you want. The strings you concatenate can be static strings (like the underscore you typed into the Name text box) or strings that are dynamically retrieved from a data source such as the Current Item data source, the Workflow Variables and Parameters data source, the Workflow Context data source, another SharePoint list, etc.

Related Articles

ADVERTISEMENTS