can please anyone tell me the right syntax of createTimer() function in a rule?
There are different definitions and examples here in the forum and in the documentations:
e.g.
createTimer( condition_expression , [ blank | command_to_call ] )
createTimer( condition_expression ) [ blank | [ command_to_call ]
createTimer( condition_expression ) , [ blank | [ command_to_call ]
The Rules DSL is based somewhat on Xtend. Extend has a bunch of “syntatic sugar” built in that lets you leave certain things out or change the definition slightly in certain contexts. I find it frustraiting and annoying and a source for confusion.
The ones that come to mind include:
getters and setters can be called as if accessing the data member directly (e.g. MyItem.getState() can become MyItem.state)
when the method doesn’t have any arguments, the parens are optional (e.g. myTimer.cancel() can become myTimer.cancel)
if the last argument of a method call is a lambda, the lambda can be defined outside of the parens (e.g. createTimer(now.plusSeconds(1), [ | logInfo("test", "test" ]) can become createTimer(now.plusSeconds(1)) [ | logInfo("test", "test" ])
As rossko57 points out, your second example is incorrect and should be