Foundation framework performSmartRule error

A workaround that works over here is to move the whole AppleScriptObjC part into a script library

Embedded Smart Rule script:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theText to plain text of theRecord
			script "Skript-Library - displayAlert"'s displayAlert(theText)
		end repeat
	end tell
end performSmartRule


Script library:

use AppleScript version "2.7"
use framework "Foundation"
use scripting additions

on displayAlert(theText)
	tell application id "DNtp"
		try
			activate
			display alert theText
			
		on error error_message number error_number
			activate
			display alert "Error: Handler \"displayAlert\"" message error_message as warning
			error number -128
		end try
	end tell
end displayAlert