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 ' and ampersands (&) to & 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 Cat‘s).
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 ' or & with the appropriate punctuation, fixing both at once. Here’s how:
- Go ahead and populate your variable or second field however you normally would (in my example, “Set Equivalent to Current Item:Name”)
- Create an if/then statement as seen above that checks for ' OR & in the Name field
- Use two separate “Replace Substring in String” actions to replace ' with ‘ and & with &. Both outputs can be to Variable: output.
- 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.