AppleScript current path for network drive or mount

applescriptautomatorfinder

I'm trying to create an AppleScript service that allows me to create a new text file in a folder in Finder. So I can right-click on a location and create a new text file. This is my flow so far:

Apple script service flow

It currently works fine for most folders. However, when I try and do this on a mounted network folder I get this error:

The action “Run AppleScript” encountered an error: “Can’t make «class cdis» "X folder" of application "Finder" into type text.”

Best Answer

Based on the following answer, I edited the AppleScript in the first step to:

on run {input, parameters}
    tell application "Finder"
        set the currentFolder to (folder of the front window as alias)
    end tell
    return currentFolder
end run

And now works correctly on network drives.