MacOS – Automator: replace text input not working

automationautomatorjavascriptmacos

What I want to do

I want to create a simple Automator service that:

  1. Takes text as input from any application,
  2. Does some logic on given input
  3. Replaces the selected input text with the calculated output

The problem

The return value in the JS script does not replace the selected input text. I have no clue why. Does anyone have experience with this?

I am running macOS Sierra 10.12, using Automator 2.7

Automator

Best Answer

The problem was related to the macOS version. After updating to 10.12.1 the text is now being correctly replaced!


Edit: for those interested in the alphabetic sorting, simply add a Run Shell Script block and fill in sort -f, like so:

Workflow script with Run Shell Script