Split document name and use characters in For Each

  • 26 February 2020
  • 3 replies
  • 9 views

Badge +2

Hi,

I have a SharePoint document Library in which users often upload documents with special characters in the document name. I'm looking for a way to detect the special characters, save them into a collection variable, replace them for valid characters and rename the document back to SharePoint. 

So, for example, document with name "Test-1-ábc", (I've already found a way to remove the extension), when running through the workflow, the "á" character needs to be replaced by a simple "a", so the new name of the document will be "Test-1-abc".  Has any one tried this before? can you please shed a light on how you would try this on your end? No need for specific expressions, just looking for ideas on how to achieve this.  Thank you!


3 replies

Badge +7
Hi Rigo,

Unfortunately, Nintex does not have a Normalize-like feature. However, one thing that you can try is to use an XML/JSon/CSV file that contains all the special characters and their equivalents (e.g. https://www.basvanbeek.nl/php/normalize-special-characters/).

Then, while iterating through the file, replace (if found), the special character with its equivalent and voila!

If you need any more help, let me know!
Badge +2

Thanks Michel,

I already have the definition of the characters that need to be replaced. I was actually looking for ideas on how to make the "replace" part happen. Fortunately I was able to figure this out after a lot of testing. My workflow now is able to complete the following steps (this is using Nintex On Prem, SharePoint 2016):

1. Detect when a new document is uploaded to the SharePoint Document Library

2. Scan the document name and remove the extension

3. Compare each character in the document name to the defined list of invalid characters

4. Change the characters that need to be changed e.g. "á" becomes "a", and remove the ones that cannot be part of the name e.g. "$" is removed from the document name

5. Concatenate all valid parts of the name and make a new name string, e.g. document "My#1Dócument2020!" will be changed to "My1Document2020"

6. Use that name string to update the file name in SharePoint, this part is actually not working yet, I expect it to be solved by tomorrow.  On the Update Item action, I select the Name property and replace with the new string. If I close that window and re-open it, the "Name" property will not be selected anymore. 

6603iBD53A61F1EB659FB.png

Thanks for taking the time to read my thread, I really hope this can help someonelse in the future; I'll be happy to share all the workflow actions I took to make this work.

 

 

Badge +7
Glad to read you've found a solution!

Reply