Dealing with &#39 and &amp in SharePoint Designer document library workflows

If you’re using a document Name field in a workflow but it’s not working as expected, it could be because there are apostrophes () or ampersands (&) in document names. In this case, SharePoint evaluates apostrophes () to &#39semicolon and ampersands (&) to &ampsemicolon As you can see here, most other punctuation evaluates perfectly well:


Note: This problem only occurs when using apostrophes and ampersands in document names, in document libraries. And we can fix the issue without needing to rename the files.

Document names cannot contain these punctuation marks: \ / . : * # “

Regular lists and document library fields aside from the Name field shouldn’t experience this issue. But if you’re using & or in your file names, and calling those file names in workflow, here’s how we can make it work:

If you just need your workflow to work because you’re checking a condition (if FileName contains Cat’s) just update the workflow to say (if FileName contains Catsemicolons).

But if you’re using the name field to set another field or workflow variable, we can clean up the result for display by replacing the &#39semicolon  or &ampsemicolon with the appropriate punctuation, fixing both at once. Here’s how:


  1. Go ahead and populate your variable or second field however you normally would (in my example, “Set Equivalent to Current Item:Name”)
  2. Create an if/then statement as seen above that checks for &#39semicolon OR & in the Name field
  3. Use two separate “Replace Substring in String” actions to replace &#39semicolon with and &ampsemicolon with &. Both outputs can be to Variable: output.
  4. Use two separate “Set Field in Current Item” actions, one after each Replace action, to set the second field (in my example, Equivalent) to Variable:output.

Now your second fields should show correct punctuation.