trim spaces in title, before using it as path

I have a simple problem, but nothing I've tried has worked.

When users paste text into the title of a new document, they sometimes pick up an extra space. Nuxeo takes the title and uses it as the document path, but then users get various 404 errors because some webui links trim that extra space.

Do I have any control over the path of a newly-created document? I've been trying to modify it in an About to Create handler which calls an automation chain. The automation javascript in studio is so frustrating, because I have to guess how it's going to map to the underlying java, with a lot of trial and error and a lot of wading through “nashorn” stack traces from the server.

Can somebody point me to a simpler solution? All I want to do is strip out the spaces before nuxeo uses that as my doc path. I guess I could do it in the create layout, but I really don't want to do that for every document type's layout. I would even settle for nonsense paths at this point, like random numbers. Our users don't care that much about the path, but they do get frustrated by the surprise 404 errors.

0 votes

0 answers



Are you using Studio? If so you solve this with an event handler and automation chain. If you don't care what the path is, you could set it to a random number or use an index.

Sorry, I see that you are using automation javascript in studio. You could just use automation chain operation Document -> SetProperty to set the name (which becomes the url part).