Automator / System Error

Hello I am new to this field. Thanks for your understanding.

I have this small automator programme which works fine

on run {input, parameters}

set dateString to do shell script "date +'%Y.%m.%d'"

tell application "System Events"

	keystroke dateString

end tell

end run

When I'm trying to run it from system preferences/keybord/services I get this error

The action “Run AppleScript” encountered an error: “The operation couldn’t be completed. (com.apple.Automator error -212.)”

My Mac version is 11.6.3

Where is the bug? Thanks

Automator / System Error
 
 
Q